N and P are essential macronutrients for all organisms. How shifts in the availability of N or P affect fungal communities in temperate forests is not well understood. Here, we conducted a factorial P × N fertilization experiment to disentangle the effects of nutrient availability on soil-residing, root-associated, and ectomycorrhizal fungi in beech (Fagus sylvatica) forests differing in P availability. We tested the hypotheses that in P-poor forests, P fertilization leads to enhanced fungal diversity in soil and roots, resulting in enhanced P nutrition of beech, and that N fertilization aggravates P shortages, shifting the fungal communities toward nitrophilic species. In response to fertilizer treatments (1 × 50 kg ha−1 P and 5 × 30 kg ha−1 N within 2 years), the labile P fractions increased in soil and roots, regardless of plant-available P in soil. Root total P decreased in response to N fertilization and root total P increased in response to P addition at the low P site. Ectomycorrhizal species richness was unaffected by fertilizer treatments, but the relative abundances of ectomycorrhizal fungi increased in response to P or N addition. At the taxon level, fungal assemblages were unaffected by fertilizer treatments, but at the order level, different response patterns for saprotrophic fungi among soil and ectomycorrhizal fungi on roots were found. Boletales increased in response to P, and Russulales decreased under N + P addition. Our results suggest that trait conservatism in related species afforded resistance of the resident mycobiome composition to nutritional imbalances.