Ecological studies on islands have provided fundamental insights into the mechanisms underlying biodiversity of larger organisms, but we know little about the factors affecting island microbial biodiversity and ecosystem function. We conducted a field experiment on five Baltic Sea islands where we placed aquatic microcosms with different levels of salinity mimicking environmental stress and allowed diatoms to colonize the microcosms via the air. Using structural equation models (SEM), we investigated the interconnections among environmental and dispersal-related factors, diatom biodiversity, and ecosystem productivity (represented by chlorophyll a concentration). We also tested whether the body size structure of the community influences productivity together with biodiversity. In SEMs, we found no relationship between species richness or evenness and productivity. However, productivity increased with increasing mean body size of species in the communities. The effects of environmental stress on both biodiversity and ecosystem productivity were highlighted as species richness and evenness declined, whereas productivity increased at the highest salinity levels. In addition to salinity, wind exposure affected both biodiversity metrics and productivity. This study provides new insights into microbial community assembly in a field experimental setting and the relationship between biodiversity and ecosystem function. Our results indicate that salinity presents a strong abiotic filter, leading to communities that may be species poor, yet comprise salinity-tolerant and relatively productive species at high salinity. Our findings also emphasize the importance of mean community body size in mediating the effects of environmental conditions on productivity and suggest that this trait should be considered more broadly in biodiversity–ecosystem function studies.