Organisms rely on inducible and constitutive immune defences to combat infection. Constitutive immunity enables a rapid response to infection but may carry a cost for uninfected individuals, leading to the prediction that it will be favoured when infection rates are high. When we exposed populations of Drosophila melanogaster to intense parasitism by the parasitoid wasp Leptopilina boulardi, they evolved resistance by developing a more reactive cellular immune response. Using single-cell RNA sequencing, we found that immune-inducible genes had become constitutively upregulated. This was the result of resistant larvae differentiating precursors of specialized immune cells called lamellocytes that were previously only produced after infection. Therefore, populations evolved resistance by genetically hard-wiring the first steps of an induced immune response to become constitutive.