All organisms experience variation in environmental conditions as weather and seasons change. This variation can induce variability in the size of a population that consequently increases the population's risk of extinction. The proposed research will experimentally test the hypothesis that heterogeneity of thermal microclimates within a habitat can reduce weather-induced variation in population dynamics. The research will analyze effects of habitat heterogeneity. Populations of Drosophila melanogaster that inhabit rotting apples in orchards will be used as a study system because both the animals and their habitat can be manipulated, and effects on individuals and populations can be quantified. The research will: (1) characterize environmental and within-habitat variation in temperature conditions that occur in apples; (2) quantify the effect of these temperature conditions on fitness of individual flies; and (3) experimentally manipulate the thermal heterogeneity of the orchard habitat to measure how it affects population dynamics of D. melanogaster. This research will contribute to a better understanding of how habitat heterogeneity and environmental variation affect animal populations. The results are especially important for conservation biology because they may improve predictions about how habitat modification will affect the persistence of rare or endangered species.