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. Fungal community assembly processes were dissimilar in different soil layers and significantly affected soil microbial community function and plant growth. 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 (1) in the 0-5 cm soil layer, grazing exclusion significantly increased the differences in SWC, SOC, KN, and N:P among the three grassland types, while the final pH, BD, TP, C:N, and C:P values were consistent with the results before exclusion. 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%. (2) 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. (3) Under the influence of both grazing exclusion and grassland type, there was no significant change in soil fungal alpha diversity, but there were significant differences in fungal beta diversity. (4) Grassland type was the most important factor influencing changes in fungal community diversity, and vegetation cover and soil kjeldahl nitrogen were the main factors influencing fungal diversity. Our research provides a long-term perspective for better understanding and managing different grasslands, as well as a better scientific basis for future research on grass-soil-microbe interactions.