The phosphorus (P) limitation induced by global nitrogen (N) enrichment continues to affect the environmental conditions and functions in grassland ecosystems. While interactions between N and carbon (C) inputs on P cycling through phosphatase activities are commonly observed, they are seldom simultaneously addressed, especially at the molecular level. A field experiment conducted in the Inner Mongolia prairie of China investigated the impacts of varying levels of N (as 0, 25, 50, 100, 200 kg N ha−1 yr−1) and C (as 0, 250, 500 kg C ha−1 yr−1) additions on the P composition, abundance, and community structure of phoD-harboring bacteria and their relationships with alkaline phosphatase (AlP). Our results indicated that high N additions (N100 and N200) significantly decreased AlP activities, while lower C addition (C250) notably increased them. N additions led to reduced abundance and altered diversity of phoD-harboring bacterial communities, while C addition weakened the connections between individual phoD-harboring bacteria, ultimately affecting the secretion of AlP. Additionally, the rates of N addition exhibited significant negative correlations with soil total phosphorus (TP) and organic phosphorus (OP). The combined additions of N and C had interactive effects on soil pH and available phosphorus (AP). Structural equation modeling revealed that soil pH, C:N ratio, and C:P ratio directly and/or indirectly influenced AlP activities, with pH being the dominant factor. Moreover, OP and AP acted as substrates and products of AlP, respectively, regulating its activities through positive and negative feedback modulation mediated by phoD gene abundance. Furthermore, our results highlight the pivotal role of Cyanobacteria as a key phylum of phoD-carrying bacteria in mediating the relationship between soil pH and AlP activity. This study sheds light on the response mechanisms of AlP activities and phoD-harboring bacterial communities to N and C additions, providing a new perspective on the P cycling process in soils.