Under strong pathogen pressure, insects often evolve resistance to infection. Many insects are also protected via immune memory (immune priming), whereby sublethal exposure to a pathogen enhances survival after secondary infection. Theory predicts that immune memory should evolve when the pathogen is highly virulent, or when pathogen exposure is relatively rare. However, there are no empirical tests of these hypotheses and the adaptive benefits of immune memory relative to direct resistance against a pathogen are poorly understood. To determine the selective pressures and ecological conditions that shape immune evolution, we imposed strong pathogen selection on flour beetle (Tribolium castaneum) populations, infecting them with Bacillus thuringiensis (Bt) for 11 generations. Populations injected first with heat-killed and then live Bt evolved high basal resistance against multiple Bt strains. By contrast, populations injected only with a high dose of live Bt evolved a less effective but strain-specific priming response. Control populations injected with heat-killed Bt did not evolve priming; and in the ancestor, priming was effective only against a low Bt dose. Intriguingly, one replicate population first evolved priming and subsequently evolved basal resistance, suggesting the potential for dynamic evolution of different immune strategies. Our work is the first report showing that pathogens can select for rapid modulation of insect priming ability, allowing hosts to evolve divergent immune strategies (generalized resistance versus specific immune memory) with potentially distinct mechanisms.