Purpose Biological nitrogen fixation (BNF) plays an important role in nitrogen cycling by transferring atmospheric dinitrogen to the soil. BNF is performed by symbiotic and asymbiotic nitrogen-fixing microorganisms. However, the abundance, activity, and community structure of diazotrophs under different nitrogen fertilizer application rates and how root exudates influence diazotrophs remain unclear. Materials and methods 15N-N2 and 13C-CO2 labeling, DNA-based stable isotope probing (SIP), and molecular biological techniques were used in this study. The abundance, activity, and structure of symbiotic and asymbiotic diazotrophs under different nitrogen fertilizer applications in paddy soil were investigated. Results and discussion We found that the nitrogen fixation capacity in milk vetch (Astragalus sinicus L.) and nifH gene abundance in the root nodules were significantly higher in the low-nitrogen treatment than in the control (zero) and high-nitrogen treatments. Nitrogen-fixing bacteria were abundant in the soils with a high biodiversity. Soil nifH gene sequences were dominated by α-, β-, and δ-proteobacteria, as well as by Cyanobacteria. The relative abundance of α-proteobacteria was lower, and the relative abundance of Cyanobacteria was higher under high nitrogen. Incubation of soil with 13CO2 and subsequent DNA-SIP analysis demonstrated that OTU65 from α-proteobacteria was relatively more abundant in heavy fractions of the 13C-labeled soils than that in the unlabeled soils, indicating that α-proteobacteria may prefer rhizodeposition carbon to other organic carbon. However, OTU24 and OTU73 from δ-proteobacteria had relatively high abundances in light fractions both in the 13C-labeled and unlabeled samples, indicating that δ-proteobacteria may prefer other soil organic carbon to rhizodeposition carbon. Conclusions The results suggested that soil N availability and rhizodeposition strongly modified the microbial communities of nitrogen-fixing bacteria. Moderate nitrogen application increased the symbiotic biological N fixing activity in the Astragalus sinicus L. rhizosphere. The BNF activity in the legume-rhizobia system is regulated by the exchange of organic C and N nutrient between the host plant and N-fixing bacteria.