The impact of biodiversity loss on the functioning of ecosystems and their ability to provide ecological services has become a central issue in ecology. Several experiments have provided evidence that reduced species diversity may impair ecosystem processes such as plant biomass production. The interpretation of these experiments, however, has been controversial because two types of mechanism may operate in combination. In the 'selection effect', dominance by species with particular traits affects ecosystem processes. In the 'complementarity effect', resource partitioning or positive interactions lead to increased total resource use. Here we present a new approach to separate the two effects on the basis of an additive partitioning analogous to the Price equation in evolutionary genetics. Applying this method to data from the pan-European BIODEPTH experiment reveals that the selection effect is zero on average and varies from negative to positive in different localities, depending on whether species with lower- or higher-than-average biomass dominate communities. In contrast, the complementarity effect is positive overall, supporting the hypothesis that plant diversity influences primary production in European grasslands through niche differentiation or facilitation.