Previous grassland biodiversity experiments were carried out in uniform environments. It is conceivable, however, that biodiversity effects on community characteristics such as primary productivity might be enhanced under more realistic levels of environmental heterogeneity, if this allows complementary resource use by different species in mixture. Therefore, we would expect larger complementarity effects between species in a heterogeneous environment than in a uniform environment. We tested these hypotheses with experiments in four non-overlapping species pools containing the three functional groups grasses, herbs and legumes. We established all species in monoculture, 3- and 6-species mixture on plots with horizontally heterogeneous or uniform distribution of the same total amount of soil nutrients. The positive net biodiversity effects on aboveground biomass production were similar in both heterogeneous and uniform environment. When the net biodiversity effects were partitioned into components, however, it became clear that in the heterogeneous environment they were due to increased complementarity among species whereas in the uniform environment dominance of species with high monoculture yield played also an important role.