In nature, the symbiotic relationship between plants and microorganisms is crucial for ecosystem balance and plant growth. This study investigates the impact of Epichloë endophytic fungi, which are exclusively present aboveground, on the rhizosphere microbial functions of the host Melica transsilvanica. Using metagenomic methods, we analyzed the differences in microbial functional groups and functional genes in the rhizosphere soil between symbiotic (EI) and non-symbiotic (EF) plants. The results reveal that the presence of Epichloë altered the community structure of carbon and nitrogen cycling-related microbial populations in the host’s rhizosphere, significantly increasing the abundance of the genes (porA, porG, IDH1) involved in the rTCA cycle of the carbon fixation pathway, as well as the abundance of nxrAB genes related to nitrification in the nitrogen-cycling pathway. Furthermore, the presence of Epichloë reduces the enrichment of virulence factors in the host rhizosphere microbiome, while significantly increasing the accumulation of resistance genes against heavy metals such as Zn, Sb, and Pb. This study provides new insights into the interactions among endophytic fungi, host plants, and rhizosphere microorganisms, and offers potential applications for utilizing endophytic fungi resources to improve plant growth and soil health.