20-hydroxyecdysone (20E) increases its titre level during the wandering stage and influences innate immunity in many holometabolous insects. However, the function of 20E as an immune-activator or -suppressor needs to be determined. Here, the transcriptome of the peptidoglycan-challenged fat body of the cotton bollworm, Helicoverpa armigera, was analysed using Illumina sequencing technology. Overall, 32 073 unigenes were assembled with a mean length of 643 nucleotides. Gene expression dynamics in the fat body during the wandering stage and of peptidoglycan-challenged individuals were investigated by the digital gene expression system. Pattern recognition receptors [such as peptidoglycan recognition protein B (PGRP B), PGRP S2 precursor, C-type lectin 5, hemolin and β-1,3-glucan recognition protein 2a] and antimicrobial peptides (namely attacin, gloverin, gloverin precursor, gloverin-like, cecropin 2, cecropin D, cecropin D-like and i-type lysozyme) significantly increased their mRNA levels during the wandering stage. 20E treatment significantly induced the expression of these genes. Antibacterial activities were also enhanced during the wandering stage and after 20E injections. Bacillus subtilis peptidoglycan induced the expression of PGRP D, PGRP B, PGRP S2 precursor, gloverin, gloverin precursor, gloverin-like, cecropin 2, cecropin D and lebocin-like genes. These results demonstrate that 20E acts by enhancing humoral immunity in H. armigera.