Abstract Epiphytic fungi are vital in enhancing their host plant performance and can also cause plant diseases. Generally, phyllosphere fungal community are majorly driven by climate, while rhizosphere fungal community are determined by soil properties and spatial distance. However, the differences in the relative effects of environmental factors on fungal community compositions and network structures remain far from clear between phyllosphere and rhizosphere. In this study, we conducted a large‐scale field survey along a 1400 km transect in the Tibetan Plateau and explored the composition and structure of phyllosphere and rhizosphere fungal communities from two dominant grass species (Leontopodium nanum and Stipa purpurea). L. nanum is widely distributed in relatively wet areas of alpine grasslands but S. purpurea prefers relatively dry areas. The geographical distributions of these two species overlap in the middle of the transect First, we found that precipitation was more important than temperature to affect fungal alpha diversity. High precipitation significantly promoted fungal alpha diversity in both phyllosphere and rhizosphere. Second, climate and spatial variables explained more variations in fungal community in the phyllosphere than rhizosphere. Specifically, greater precipitation promoted the relative abundances of pathotrophic fungi in the phyllosphere and rhizosphere, whereas lower precipitation only stimulated the relative abundances of symbiotrophic fungi in the rhizosphere. Third, precipitation had different impacts on phyllosphere and rhizosphere fungal networks between host species. Drought caused lower node number of fungal networks in the phyllosphere and rhizosphere of L. nanum. However, for S. purpurea, drought led to more complex and positive fungal networks in the phyllosphere and rhizosphere. Overall, these results indicated that precipitation caused different fungal community compositions along the transect between phyllosphere and rhizosphere, but consistently shaped their fungal networks. This study is among the first to provide compelling evidence on the large‐scale spatial variations and controlling factors for epiphytic fungal community in alpine grasslands. These new findings help to understand the role of epiphytic fungal community in affecting the functions of alpine grasses to cope with extreme environments. Read the free Plain Language Summary for this article on the Journal blog.