The influence of biodiversity on ecosystem functioning has been the focus of much recent research, but the role of environmental context and the mechanisms by which it may influence diversity effects on production and stability remain poorly understood. We assembled marine macroalgal communities in two mesocosm experiments that varied nutrient supply, and at four field sites that differed naturally in environmental conditions. Concordant with theory, nutrient addition promoted positive species richness effects on algal growth in the first mesocosm experiment; however, it tended to weaken the positive diversity relationship found under ambient conditions in a second experiment the next year. In the field experiments, species richness increased algal biomass production at two of four sites. Together, these experiments indicate that diversity effects on algal biomass production are strongly influenced by environmental conditions that vary over space and time. In decomposing the net biodiversity effect into its component mechanisms, seven of the eight experimental settings showed positive complementarity effects (suggesting facilitation or complementary resource use) countered by negative selection effects (i.e. enhanced growth in mixture of otherwise slow growing species) to varying degrees. Under no conditions, including nutrient enrichment, did we find evidence of positive selection effects commonly thought to drive positive diversity effects. Species richness enhanced stability of algal community biomass across a range of environmental settings in our field experiments. Hence, while species richness can increase production, enhanced stability is also an important functional outcome of maintaining diverse marine macroalgal communities.