Pine wilt disease (PWD) is a worldwide forest disease caused by pine wood nematode (PWN). In this article, we investigated the composition, organization, correlation, and function of the endophytic microbial community in Pinus massoniana field with and without PWN. Samples were taken from branches, upper, middle, and lower trunks, as well as soil, from both healthy and infected trees. The results showed that the fungal diversity of healthy pines is around 1.1 times that of infected pines, while the bacterial diversity is about 0.75 times that of infected pines at the OTUs level. An increase of the abundance of pathogenic fungus such as Saitozyma, Graphilbum, Diplodia, Candida, Pseudoxanthomonas, Dyella and Pantoea was witnessed in infected pines according to the result of LEfSe. Furthermore, Ophiostoma and saprophytic fungus such as Entomocorticium, ganoderma, tomentella, entomocorticium were exclusively prominent in infected pines, which were substantially and highly connected with other species (p < 0.05), indicating the trees’ vulnerability and making the wood blue. In healthy pines, the top three functional guilds are parasites, plant pathogens, and saprotrophs. Parasites (36.52%) are primarily found in the branches, plant pathogens (29.12%) are primarily found in the lower trunk, and saprotrophs (67.88%) are primarily found in the upper trunk of disease trees. Pines’ immunity is being eroded due to an increase in the quantity and types of diseases. PICRUSt2 research revealed that NADH or NADPH, as well as carbon-nitrogen bonds, were more abundant in healthy pines, but acid anhydrides and transferring phosphorus-containing groups were more abundant in infected pines. The shift in resin secretion lowers the tree’s potential and encourages pine wilt and mortality. In total, PWN may have disrupted the microbiological ecology and worked with the community to hasten the demise of pines.