Plant diversity has often been linked to increased productivity. However, this apparent diversity-productivity relationship for plants may rely on interactions with microbes. Furthermore, these relationships are likely to be context dependent in response to resource availability. We used a biodiversity-ecosystem function experiment with trees exposed to high and low water availability treatments to determine if soil fungal communities mediate the diversity-productivity relationship. We found that richness and community composition of soil fungi and the interaction between plant pathogen and ectomycorrhizal richness were significant drivers of above-ground productivity and supported indirect, positive effects of tree species richness and functional diversity on productivity. Soil fungi also mediated tree water relations, reducing the effect of water limitation on productivity. Fungal communities were important drivers of positive net diversity and complementarity effects on productivity. Our study provides evidence that soil fungi play an important role in diversity-productivity relationships under variable water availability.