Environmental variability can significantly impact individual survival and reproduction. Meanwhile, high population densities can lead to resource scarcity and increased exposure to parasites and pathogens. Studies with insects can offer valuable insights into eco-immunology, allowing us to explore the connections between these variables. Here we use the moth Anticarsia gemmatalis to examine how increases in population density and immunological challenge during the larval stage shape its investment in immune defence and reproduction. Larvae reared at a high population density exhibited greater lytic activity against bacteria compared to those reared at low density, whilst bacterial challenge (i.e. bacteria-immersed needles) also increased lytic activity. There was no interaction between the variables population density and bacterial challenge, indicating that these are independent. Surprisingly, neither increase in lytic activity carried through to activity in prepupal haemolymph. Rearing of larvae at a high density delayed pupation and decreased pupal weight. The immunological stimulus did not significantly influence pupal development. Lower population density as a larva resulted in greater adult weight, but did not significantly influence lytic activity in the eggs or the number of eggs laid. Negative correlations were found between lytic activity in the eggs and the number of eggs, as well as between adult weight and the number of eggs. Overall, this study demonstrates that high population density and immune challenge trigger increased lytic activity in caterpillars, but this effect is transient, not persisting into later stages. The trade-offs observed, such as delayed pupation and reduced prepupal weights under high density, suggest a balancing act between immune investment and developmental aspects. The findings hint at a short-term adaptive response rather than a sustained strategy. The implications of delayed pupation and smaller adult moths could influence the moth's life history strategy, impacting its role in the ecosystem. Further research tracking larval immune investment and subsequent reproductive success will unveil the evolutionary dynamics of this relationship in changing environments.