Microorganisms play an important role in soil phosphorus (P) cycling and regulation of P availability in agroecosystems. However, the responses of the functional and ecological traits of P-transformation microorganisms to long-term nutrient inputs are largely unknown. This study used metagenomics to investigate changes in the relative abundance of microbial P-transformation genes at four long-term experimental sites that received various inputs of N and P nutrients (up to 39 years). Long-term P input increased microbial P immobilization by decreasing the relative abundance of the P-starvation response gene (
phoR) and increasing that of the low-affinity inorganic phosphate transporter gene ( pit). This contrasts with previous findings that low-P conditions facilitate P immobilization in culturable microorganisms in short-term studies. In comparison, long-term nitrogen (N) input significantly decreased soil pH, and consequently decreased the relative abundances of total microbial P-solubilizing genes and the abundances of Actinobacteria, Gammaproteobacteria, and Alphaproteobacteriacontaining genes coding for alkaline phosphatase, and weakened the connection of relevant key genes. This challenges the concept that microbial P-solubilization capacity is mainly regulated by N:P stoichiometry. It is concluded that long-term N inputs decreased microbial P-solubilizing and mineralizing capacity while P inputs favored microbial immobilization via altering the microbial functional profiles, providing a novel insight into the regulation of P cycling in sustainable agroecosystems from a microbial perspective.