The fixation and transfer of biological nitrogen from peanuts to maize in maize–peanut intercropping systems play a pivotal role in maintaining the soil nutrient balance. However, the mechanisms through which root interactions regulate biological nitrogen fixation and transfer remain unclear. This study employed a 15N isotope labelling method to quantify nitrogen fixation and transfer from peanuts to maize, concurrently elucidating key microorganisms and genera in the nitrogen cycle through metagenomic sequencing. The results revealed that biological nitrogen fixation in peanut was 50 mg and transfer to maize was 230 mg when the roots interacted. Moreover, root interactions significantly increased nitrogen content and the activities of protease, dehydrogenase (DHO) and nitrate reductase in the rhizosphere soil. Metagenomic analyses and structural equation modelling indicated that nrfC and nirA genes played important roles in regulating nitrogen fixation and transfer. Bradyrhizobium was affected by soil nitrogen content and DHO, indirectly influencing the efficiency of nitrogen fixation and transfer. Overall, our study identified key bacterial genera and genes associated with nitrogen fixation and transfer, thus advancing our understanding of interspecific interactions and highlighting the pivotal role of soil microorganisms and functional genes in maintaining soil ecosystem stability from a molecular ecological perspective.