Abstract. We consider the evolution of ecological specialization in a landscape with two discrete habitat types connected by migration, for example, a plant-insect system with two plant hosts. Using a quantitative genetic approach, we study the joint evolution of a quantitative character determining performance in each habitat together with the changes in the population density. We find that specialization on a single habitat evolves with intermediate migration rates, whereas a generalist species evolves with both very low and very large rates of movement between habitats. There is a threshold at which a small increase in the connectivity of the two habitats will result in dramatic decrease in the total population size and the nearly complete loss of use of one of the two habitats through a process of ''migrational meltdown.'' In some situations, equilibria corresponding to a specialist and a generalist species are simultaneously stable. Analysis of our model also shows cases of hysteresis in which small transient changes in the landscape structure or accidental demographic disturbances have irreversible effects on the evolution of specialization. Phytophagous insects feeding on different plant species and parasites exploiting different hosts face conflicting selection pressures due to the heterogeneous nature of their habitats. It is therefore not surprising that the study of such systems has led to so many fruitful insights (Futuyama and Moreno 1988;Jaenike 1990;Via 1991) and raised so many theoretical questions about broad issues, such as the evolution of source-sink dynamics (Pulliam 1988;Holt 1996b) and the evolution of ecological specialization (Levins 1968;Berenbaum 1996;Fry 1996). The nature of the genetic and ecological factors that limit the niche breadth of a species in a heterogeneous habitat still remains largely an open question. In this paper, we suggest that host range evolution may be very sensitive to demographic disturbances affecting both population densities and migration patterns in a heterogeneous habitat.The present theoretical study is inspired by the dynamics and rapid evolution of a heterogeneous metapopulation of the checkerspot butterfly, Euphydryas editha Thomas et al. 1996;Boughton 1999). Before 1989, larvae of E. editha were found on two host plants. Populations on Collinsia torreyi behaved as source populations exporting migrants to pseudo-sink populations on Pedicularis semibarbata. The accidental extinction of populations on Collinsia, due to an unusual summer frost in the early 1990s, was followed by a complete reversal in source-sink dynamics and a dramatic narrowing of the butterfly diet (Boughton 1999). Since the disturbance, local populations have not regained the ability to use their former host, Collinsia. This example suggests that demographic disturbances may play an important role in the evolution of ecological specialization leading to rapid shifts in host use.Several models have explored how the interactions between demography and local adaptation may shape the nic...