Soil microorganisms play a key role in soil P transformation and cycling in grassland ecosystems, while the microbial mechanisms of animal grazing mediating soil P processes are not fully understood. We conducted a grazing experiment in a typical steppe grassland in Inner Mongolia, to explore the responses of microbial communities in rhizosphere and bulk soils to grazing intensity for understanding the mechanisms of grazing affecting P cycling. We determined soil physico-chemical properties and alkaline phosphatase activities, and measured soil microbial diversity and the relative abundance of microbial P-transformation genes by metagenomics in the rhizosphere and bulk soils of a Stipa grandis dominated grassland under three grazing intensities (no-, moderate, and heavy grazing). We found that (i) grazing significantly increased soil available P concentration and soil alkaline phosphatase activity; (ii) grazing increased the abundance of bacterial, but not fungal communities, and the enhanced abundance of rhizosphere bacteria promotes the P-cycling potential; (iii) grazing increased the relative abundance of the genes responsible for microbial P-uptake and transport, and inorganic P solubilization and organic P mineralization in rhizosphere soil, but not in bulk soil; (iv) grazing reduced the node degree of the network of the genes involved in P-transformation, but it increased the node degree of the genes encoding alkaline phosphatase and the C–P lyase multi-enzyme complex in the rhizosphere soil. The grazing-induced changes in the abundance of microbial functional genes are beneficial to P-solubilization and mineralization. Our results indicate a divergent effect of grazing on soil microbial communities and their functional genes involved P-transformation in rhizosphere and bulk soils, and represent an important progress towards the understanding of the mechanisms of microbial regulation of P cycling in grassland ecosystems.