Studies investigating the impacts of biodiversity loss on ecosystem processes have often reached different conclusions, probably because insufficient attention has been paid to some aspects including (1) which biodiversity measure (e.g., species number, species identity or trait) better explains ecosystem functioning, (2) the mechanisms underpinning biodiversity effects, and (3) how can environmental context modulates biodiversity effects. Here, we investigated how species number (one to three species) and traits of aquatic fungal decomposers (by replacement of a functional type from an unpolluted site by another from a metal-polluted site) affect fungal production (biomass accumulation) and plant litter decomposition in the presence and absence of metal stress. To examine the putative mechanisms that explain biodiversity effects, we determined the contribution of each fungal species to the total biomass produced in multicultures by real-time PCR. In the absence of metal, positive diversity effects were observed for fungal production and leaf decomposition as a result of species complementarity. Metal stress decreased diversity effects on leaf decomposition in assemblages containing the functional type from the unpolluted site, probably due to competitive interactions between fungi. However, dominance effect maintained positive diversity effects under metal stress in assemblages containing the functional type from the metal-polluted site. These findings emphasize the importance of intraspecific diversity in modulating diversity effects under metal stress, providing evidence that trait-based diversity measures should be incorporated when examining biodiversity effects.