Plant productivity varies due to environmental heterogeneity, and theory suggests that plant diversity can reduce this variation. While there is strong evidence of diversity effects on temporal variability of productivity, whether this mechanism extends to variability across space remains elusive. Here we determine the relationship between plant diversity and spatial variability of productivity in 83 grasslands, and quantify the effect of experimentally increased spatial heterogeneity in environmental conditions on this relationship. We found that communities with higher plant species richness (alpha and gamma diversity) have lower spatial variability of productivity as reduced abundance of some species can be compensated for by increased abundance of other species. In contrast, high species dissimilarity among local communities (beta diversity) is positively associated with spatial variability of productivity, suggesting that changes in species composition can scale up to affect productivity. Experimentally increased spatial environmental heterogeneity weakens the effect of plant alpha and gamma diversity, and reveals that beta diversity can simultaneously decrease and increase spatial variability of productivity. Our findings unveil the generality of the diversity-stability theory across space, and suggest that reduced local diversity and biotic homogenization can affect the spatial reliability of key ecosystem functions.