The brown planthopper (Nilaparvata lugens, BPH) is a destructive insect pest posing a serious threat to rice production. The fungal entomopathogen Metarhizium anisopliae is a promising alternative that can be used for BPH biocontrol. Recent studies have highlighted the significant involvement of gut microbiota in the insect–fungus interactions. In the presented study, we investigated the effects of topical fungal infection on the gut microbial community structure in BPH. Our results revealed that topical infection with M. anisopliae increased the bacterial load and altered the bacterial community structure in the gut of BPH. The relative abundances of the dominant gut bacteria at the order, family and genus level were significantly different between fungus-infected and uninfected groups. At the genus level, the uninfected BPH harbored high proportions of Pantoea and Enterobacter in the gut, whereas the fungus-infected BPH gut was absolutely dominated by Acinetobacter. Moreover, topical fungal infection significantly inhibited the expressions of immune-related genes encoding anti-microbial protein and dual oxidase that were involved in the maintenance of gut microbiota homeostasis, indicating that gut bacteria imbalance might be attributed in part to the suppression of gut immunity caused by fungal pathogen. Our results highlighted the importance of the gut microbial community during interactions between fungal pathogens and insect hosts.