Endophytic fungi are a crucial microbial resource that can influence plant growth and development through their interactions with host plants. Gentiana straminea Maxim. is an important traditional Tibetan herb used to treat a range of diseases in the Qinghai-Tibetan region. However, the diversity and community structure of endophytic fungi in the species remain poorly understood. In this study, a total of 944 strains of endophytic fungi were isolated from the roots, stems, and leaves of G. straminea from four different altitudes. A total of 87 OTUs were identified through sequence alignment, comprising 6 classes, 15 orders, 25 families, and 44 genera. The colonization rate and diversity of endophytic fungi were affected by tissue type and altitude. With the exception of Xining, the endophytic fungi colonization rate of tissues was roots>leaves>stems. Moreover, the α-diversity of endophytic fungi among different tissues was leaves>stems>roots. Notably, the phylogenetic diversity index in leaves was significantly higher than that in roots. In addition, the colonization rate and diversity of endophytic fungi in leaves and stems demonstrated a decline with the increasing altitude. The β-diversity analysis revealed significant differences in the endophytic fungi of G. straminea at varying altitudes. In roots, geographical factors, such as latitude and longitude, were the primary drivers of variation, whereas environmental factors, including temperature and precipitation, had a greater influence on endophytes in leaves and stems. In addition, the results of the endophytic fungi association preference, linear discriminant analysis effect size (LEfSe), and co-network analysis indicated that these differential endophytic fungi may play a significant role in the authenticity and stress resistance of G. straminea.