Encounters with parasites and pathogens are often unpredictable in time. However, experience of an infection may provide the host with reliable cues about the future risk of infection for the host itself or for its progeny. If the parental environment predicts the quality of the progeny's environment, then parents may further enhance their net reproductive success by differentially providing their offspring with phenotypes to cope with potential hazards such as pathogen infection. Here, I test for the occurrence of such an adaptive transgenerational phenotypic plasticity in the mealworm beetle, Tenebrio molitor. A pathogenic environment was mimicked by injection of bacterial lipopolysaccharides for two generations of insects. I found that parental challenge enhanced offspring immunity through the inducible production of antimicrobial peptides in the haemolymph.