Soil fungi are fundamental to plant productivity, yet their influence on the temporal stability of global terrestrial ecosystems, and their capacity to buffer plant productivity against extreme drought events, remain uncertain. Here we combined three independent global field surveys of soil fungi with a satellite-derived temporal assessment of plant productivity, and report that phylotype richness within particular fungal functional groups drives the stability of terrestrial ecosystems. The richness of fungal decomposers was consistently and positively associated with ecosystem stability worldwide, while the opposite pattern was found for the richness of fungal plant pathogens, particularly in grasslands. We further demonstrated that the richness of soil decomposers was consistently positively linked with higher resistance of plant productivity in response to extreme drought events, while that of fungal plant pathogens showed a general negative relationship with plant productivity resilience/resistance patterns. Together, our work provides evidence supporting the critical role of soil fungal diversity to secure stable plant production over time in global ecosystems, and to buffer against extreme climate events.