The theory of insect population dynamics has shown that heterogeneity in natural-enemy attack rates is strongly stabilizing. We tested the usefulness of this theory for outbreaking insects, many of which are attacked by infectious pathogens. We measured heterogeneity among gypsy moth larvae in their risk of infection with a nucleopolyhedrovirus, which is effectively heterogeneity in the pathogen's attack rate. Our data show that heterogeneity in infection risk in this insect is so high that it leads to a stable equilibrium in the models, which is inconsistent with the outbreaks seen in North American gypsy moth populations. Our data further suggest that infection risk declines after epidemics, in turn suggesting that the model assumption of constant infection risk is incorrect. We therefore constructed an alternative model in which natural selection drives fluctuations in infection risk, leading to reductions after epidemics because of selection for resistance and increases after epidemics because of a cost of resistance. This model shows cycles even for high heterogeneity, and experiments confirm that infection risk is indeed heritable. The model is very general, and so we argue that natural selection for disease resistance may play a role in many insect outbreaks.