Groundwater serves as a critical driver in extremely arid regions, which influences soil carbon content of desert ecosystems. However, how soil carbon fractions vary with groundwater depth and the underlying mechanisms remain poorly understood. In this study, we analyzed the distributions of soil carbon components in sites with different groundwater depths (2.5, 4.5, and 11.0 m) at the southern edge of the Taklamakan Desert. The results showed that both coarse particulate organic carbon (cPOC) and mineral-associated organic carbon (MAOC) reached peak concentrations at the 4.5 m depth, with cPOC significantly increased by 1059.57% compared with 11.0 m and MAOC increased by 37.50% compared with 2.5 m. In contrast, no significant differences were observed in the labile and recalcitrant carbon fractions across the different groundwater depths. Groundwater depth and microbial biomass carbon were identified as the primary regulators of cPOC, while peroxidase activity and microbial biomass carbon were the key drivers for the formation and accumulation of MAOC. Mechanistic analysis revealed that groundwater depth regulates the transformation and accumulation of soil carbon fractions by altering microbial biomass carbon and peroxidase activity. This study enhances the understanding of how soil carbon pools in extremely arid desert ecosystems respond to changes in groundwater level, and provides a theoretical basis and practical guidance for water resource management and the enhancement of ecosystem carbon sink function in arid regions.