Plant-microbe interactions could significantly shape forest dynamics, yet the molecular functions and contributions of plant-associated microbes to seedling survival and species coexistence remain largely unknown. This research aims to bridge functional genomics and ecological modeling to investigate how endophytes influence seedling survival and plant community assembly in a subtropical forest. We found that endophytic gene number was significantly associated with plant divergence time and maximum height. 113 endophytic GOs significantly enhanced seedling survival, and the GO group of stimulus responses had a higher proportion of fitness-related GOs, implying that endophyte-mediated stimulus responses are important for host fitness. We also found significantly stronger phylogenetic signals for fitness-related and stimulus-response-related GOs, suggesting that endophyte-mediated fitness and stimulus responses are associated with host evolution. This study reveals how foliar endophytes enhancing host survival and coexistence from a functional genomics perspective, emphasizing their critical role in forest ecosystem functioning and biodiversity conservation.