Effects of endophytes infection on bacterial and fungal communities in soil have been extensively studied. However, how the presence of Epichloë endophytes and environmental factors influence the nitrifying genes abundance of ammonia-oxidizing archaea (amoA-AOA) and bacteria (amoA-AOB), and denitrifying genes abundances of N reduction (nirS and nirK) and nitrous oxide reduction (nosZ) in soil is unclear. In the study, the copy number of 16S rRNA, 18S rRNA, amoA-AOB, amoA-AOA, nirS, nirK, and nosZ genes in rhizosphere soils of drunken horse grass [Achnatherum inebrians (Hance) Keng] with the infected (E+) and uninfected (E-)endophyte five ecotypes after 3 yr field cultivation were investigated using quantitative polymerase chain reaction (PCR). The effects of A. inebrians in geographic source on plant growth, soil fertility, and microbial community was greater than in different endophyte status. The copy number of the 16S rRNA, amoA-AOA, nirK, and nosZ genes from different ecotypes (Qinghai, QH; and Tianzhu, TZ) were significantly affected by Epichloë endophyte. The copy number of the 16S rRNA, 18S rRNA, amoA-AOB. amoA-AOA, nirS, nirK, and nosZ genes positively related to soil pH, moisture, C/N ratio, and soil ammonium nitrogen (NH 4 + ), and soil organic carbon (SOC) contents.Endophyte infection significantly increased plant biomass of A. inebrians from QH ecotype. Plant total chlorophyll and soil nitrate nitrogen (NO 3 -) were the main factor for the Epichloë endophyte and ecotype to affect plant dry weight. Further studies are required to confirm the regulation of soil NO 3 as an important factor in Epichloë endophyte affecting plant growth and the soil microbial community structure in relation to N cycling.