There is an increasing appreciation of the importance of transgenerational effects on offspring fitness, including in relation to immune function and disease resistance. Here, we assess the impact of parental rearing density on offspring resistance to viral challenge in an insect species expressing density-dependent prophylaxis (DDP); i.e. the adaptive increase in resistance or tolerance to pathogen infection in response to crowding. We quantified survival rates in larvae of the cotton leafworm (Spodoptera littoralis) from either gregarious- or solitary-reared parents following challenge with the baculovirus S. littoralis nucleopolyhedrovirus. Larvae from both the parental and offspring generations exhibited DDP, with gregarious-reared larvae having higher survival rates post-challenge than solitary-reared larvae. Within each of these categories, however, survival following infection was lower in those larvae from gregarious-reared parents than those from solitary-reared, consistent with a transgenerational cost of DDP immune upregulation. This observation demonstrates that crowding influences lepidopteran disease resistance over multiple generations, with potential implications for the dynamics of host–pathogen interactions.