BACKGROUNDBaculoviruses such as Helicoverpa armigera nucleopolyhedrovirus (HearNPV) infect their lepidopteran hosts via the larval midgut where they interact with host immune responses and gut microbiota. Here we demonstrate that gut microbiota proliferating in response to HearNPV infection promote larval immune responses which impede the infection process.RESULTSThe microbial load of the larval midgut increased following HearNPV infection, due primarily to increases in Enterococcus spp., whereas most other bacterial genera declined, with Firmicutes replacing Proteobacteria as the dominant phylum. Injection of abdominal prolegs of infected larvae with H2O2 promoted viral infection, diminished microbial abundance, and accelerated larval death, mimicking the effects of HearNPV infection, which up‐regulated dual oxidase (Duox) expression, increasing H2O2 levels in the midgut. Knockdown of Duox with RNAi reduced H2O2 production in the guts of infected larvae, increased bacterial loads, decreased viral replication, and improved larval survival. Germ‐free larvae were more susceptible to HearNPV than control larvae, exhibiting greater expression of Duox, higher levels of H2O2, and lower survival. Replenishment of gut bacteria in germ‐free larvae restored the base‐line immunity to HearNPV observed in normal larvae. Enterococcus spp., Levilactobacillus brevis, and Lactobacillus sp. bacteria were isolated and implicated in immunity restoration via replenishment in germ‐free larvae.CONCLUSIONThese findings illuminate how gut microbiota play important roles in larval defense against oral baculovirus infection, and suggest novel avenues of investigation to enhance the efficacy of baculoviruses and improve control of lepidopteran pests. © 2023 Society of Chemical Industry.