Soil fungi are involved in the decomposition of organic matter, and they alter soil structure and physicochemical properties and drive the material cycle and energy flow in terrestrial ecosystems. Grazing exclusion is one of the most common measures used to restore degraded grasslands worldwide. However, changes in soil fungal community characteristics during grazing exclusion in different types of grasslands are unknown. Here, we investigated the effects of a 9-year grazing exclusion on soil properties, fungal community composition and diversity in three grassland types (temperate desert, temperate steppe and mountain meadow). The results showed that in the 0-5 cm soil layer, grazing exclusion significantly affected the physicochemical parameters of all three studied grassland types. In the 5-10 cm soil layer, grazing exclusion significantly increased total phosphorus (TP) in temperate deserts by 34.1%, while significantly decreasing bulk density (BD) by 9.8% and the nitrogen: phosphorus ratio (N:P) by 47.1%. The soil fungal community composition differed among the grassland types, For example, significant differences were found among the three grassland types for the Glomeromycota and Mucoromycota, Grazing exclusion, grassland type, and the interaction between the two did not significantly affect soil fungal α-diversity or community composition(P > 0.05), but significantly altered fungal β-diversity (P < 0.05). Overall, our results highlight the importance of soil nutrient content, especially soil Kjeldahl nitrogen, total phosphorus and organic carbon on fungal diversity, and the results provide key insights into how soil fungi respond to grazing exclusion in different grassland types.