BackgroundThe insect hemolymph (blood-equivalent fluid), composed of a large number of hemocytes (blood cells) and a variety of soluble immune effectors, is hostile for pathogens including fungi. In order to survive in the insect hemocoel (body cavity), the entomopathogenic fungus (EPF) has evolved two classical coping strategies, namely evasion and suppression of the host immune reactions. However, it remains unclear whether EPF has other ways of coping with host immunity.ResultsIn this study, we demonstrated thatMetarhizium rileyi(an EPF) infection by injection of blastospores into the hemocoel enhanced the plasma antibacterial activity of cotton bollworm (Helicoverpa armigera), which was partially due to the enhanced expression of antimicrobial peptides (AMPs). The early stage ofM. rileyiinfection induced the translocation of gut bacteria into the hemocoel, where they were subsequently cleared due to the enhanced plasma antibacterial activity. Further, we showed that the enhanced plasma antibacterial activity and AMP expression were attributable toM. rileyibut not the invasive gut bacteria (opportunistic bacteria). Elevated ecdysone (major steroid hormone in insects) levels in the hemolymph at 48 h post-M. rileyiinfection might contribute to the enhanced expression of AMPs. The fungus-elicited AMPs, such as cecropin 3 or lebocin, exhibited potent inhibitory activity against the opportunistic bacteria but not against hyphal bodies. In addition, the opportunistic bacteria competed with hyphal bodies for amino acid nutrients.ConclusionsM. rileyiinfection induced the translocation of gut bacteria, and then the fungi activated and exploited its host humoral antibacterial immunity to eliminate opportunistic bacteria, preventing them from competing for nutrients in the hemolymph. Unlike the classical strategies, EPF utilizes to evade or suppress host immunity, our findings reveal a novel strategy of interaction between EPF and host immunity.Video AbstractSupplementary InformationThe online version contains supplementary material available at 10.1186/s40168-023-01538-6.