This study investigates the impact of Bursaphelenchus xylophilus infection on the gut bacterial communities of the pine sawyer beetle, Monochamus alternatus, with a distinction between male and female individuals. Utilizing specific primers, we determined the infection status and analyzed the bacterial composition across different taxonomic levels. Regardless of infection status or sex, Proteobacteria and Firmicutes were found to dominate the phylum level, with significant contributions from Actinobacteria and Bacteroidetes. At the class level, Bacilli, Gammaproteobacteria, Alphaproteobacteria, and Actinobacteria emerged as prevalent groups. Meanwhile, the genus level was characterized by a high abundance of Lactobacillus, Rickettsia, Bacillus, and Rahnella. Our analysis of alpha diversity metrics, including Observed Species, Shannon Index, Inverse Simpson Index, and Phylogenetic Diversity, revealed no significant differences attributable to B. xylophilus infection; however, notable variations were observed between sexes. Principal Coordinates Analysis and Non-metric Multidimensional Scaling further underscored that the differences in gut bacterial communities were more pronounced between male and female beetles than between infected and uninfected individuals. These findings highlight the influence of host sex over infection status in shaping the gut microbiome of Monochamus alternatus, providing new insights into the complex interactions between host biology, gut microbiota, and pathogen infection.