Positive biodiversity–ecosystem‐functioning (BEF) relationships are commonly found in experimental and observational studies, but how they vary in different environmental contexts and under the influence of coexisting life forms is still controversial. Investigating these variations is important for making predictions regarding the dynamics of plant communities and carbon pools under global change. We conducted this study across 433 shrubland sites in northern China. We fitted structural equation models (SEMs) to analyze the variation in the species‐richness–biomass relationships of shrubs and herbs along a wetness gradient and general liner models (GLMs) to analyze how shrub or herb biomass affected the species‐richness–biomass relationship of the other life form. We found that the positive species‐richness–biomass relationships for both shrubs and herbs became weaker or even negative with higher water availability, likely indicating stronger interspecific competition within life forms under more benign conditions. After accounting for variation in environmental contexts using residual regression, we found that the benign effect of greater facilitation by a larger shrub biomass reduced the positive species‐richness–biomass relationships of herbs, causing them to become nonsignificant. Different levels of herb biomass, however, did not change the species‐richness–biomass relationship of shrubs, possibly because greater herb biomass did not alter the stress level for shrubs. We conclude that biodiversity in the studied plant communities is particularly important for plant biomass production under arid conditions and that it might be possible to use shrubs as nurse plants to facilitate understory herb establishment in ecological restoration.