AbstractElevation changes create gradients in abiotic factors, which in turn affect soil erosion and carbon cycling. However, how elevation changes control soil ecological processes through temperature and the mechanism that affects the carbon cycle remain unclear. Therefore, we have studied the distribution of temperature, bulk density (BD), soil pH, mean weight diameter (MWD), clay, and diversity of soil fungal community diversity, and discussed the critical factors affecting soil organic carbon (SOC) and nitrogen (N) in a typical karst mountainous area. The results showed that the dominant phyla were Ascomycota (42.28%), Mortierellomycota (20.6%), Basidiomycota (17.83%), and Rozellomycota (11.82%). The elevation distributions of MWD, fungal diversity, the rate of SOC and N stocks change per temperature index, and SOC and N stocks all exhibited unimodal patterns. Additionally, temperature, fungal diversity, MWD, BD, and clay were the dominant factors explaining the variability of SOC and N, and SOC and N had a positive relationship with pH, BD, MWD, clay‐silt content, warmth index, and Sobs and Shannon diversity. Analyses showed that the warmth index regulated soil aggregates through fungal diversity and combined with BD to affect carbon sequestration, which was controlled by clay, the C:N ratio, and pH during the process. These conclusions have important implications for improving the SOC sequestration capacity in karst mountainous areas.