Polygonatum cyrtonema Hua (PCH), as an important economic crop, is used as raw industrial materials and traditional Chinese medicine. There are significant variations in the quality of PCH from different geographical origins. It can be due to the change of the endophytic fungi and soil microbial communities of PCH. Therefore, the aim of this study is to investigate the composition and functional prediction of the main microbial communities in the rhizomes and soil of PCH and explore their impact on medicinal quality. High-throughput sequencing techniques targeting ITS and 16S rDNA were employed to compare the structure and biodiversity differences of endophytic fungi in the rhizomes and soil microbial communities of PCH from 12 different locations in Sichuan and Guangxi province. Heatmap analysis was used for comprehensive statistics and visualization of the richness of rhizome and soil microbial communities from all locations. Venn analysis was conducted to determine the total number of shared fungi between rhizomes and soil, and GraphPad Prism analysis was employed to predict and compare the microbial communities related to phenotypes at the genus level in Sichuan and Guangxi. Tax4Fun and Fungild were used for metabolic function prediction of microbial communities in the rhizomes and soil of PCH. The results revealed the identification of 19,387 bacterial amplicon sequence variants (ASVs) in the rhizomes and 37,990 bacterial ASVs in the soil, with 6,889 shared bacterial ASVs. In addition, 2,948 fungal ASVs were identified in the rhizomes and 8,868 in the soil, with 1,893 shared fungal ASVs. Microbial sequencing results indicated that the fungal communities between soil and rhizomes were mainly composed of Ascomycota and Basidiomycota, while bacterial communities included Proteobacteria, Acidobacteria, Bacteroidota, Gammatimonadota, and Firmicutes. Dominant bacterial groups such as Nitrospira, Acidibacter, and fungal groups including Mortierella, Ceratobasidium, and Fusarium were identified as potential contributors to the observed traits. In the top 15 microbial genera, both Sichuan and Guangxi contain 15 bacterial genera, but there are differences in their abundance. Guangxi has three unique fungal genera, including the genera Scleroderma, Russula, and Gliocladiopsis. On the other hand, Sichuan has the unique fungal genus Chamaeota. The correlation analysis between the microbiota and the chemical content from 12 different collecting spots was performed by GraphPad Prism. Burkholderia-Caballeronia-Paraburkholderia, Acidibacter, and Amycolatopsis show an inverse proportionality to total polysaccharides and saponins, while Enterobacter shows a direct proportionality to total polysaccharides and inverse proportionality to saponins. The metabolism pathways show a significant positive correlation with PCH polysaccharides and saponins. This study provide new insights into the mechanisms underlying the quality differences between the two major indigenous areas.