Using a simple two-patch model, we examine how patterns of spatial and temporal variation in carrying capacities affect natural selection on dispersal. The size of the population in each patch is regulated separately, according to a discrete-generation logistic equation, and individuals disperse from each patch at propensities determined by their genotype. We consider genotypes that express the same dispersal propensities in both patches and genotypes that express patch-specific disperal propensities. Contrary to previous analyses, our results show that some level of dispersal is favored by selection under almost all regimes of habitat variability, including a spatially varying and temporally constant environment. Furthermore, two very different polymorphisms are favored under different conditions. When carrying capacities vary spatially but not temporally, any number of genotypes with patch-specific dispersal propensities in ratios inversely proportional to the ratio of the carrying capacities can coexist. This result extends previous analyses to show that dispersal is favored in such an environment if individuals can alter dispersal propensities in response to environmental cues. In contrast, when carrying capacities vary both spatially and temporally but differ in mean or variance, a polymorphism of only two genotypes (a high-dispersal and a no-dispersal genotype) is favored when the only genotypes possible are ones expressing the same dispersal propensity in both patches. However, this dimorphism can be invaded and replaced by one genotype with a particular combination of patch-specific dispersal propensities in a ratio also inversely proportional to the ratio of the average population sizes. We discuss a number of testable predictions this model suggests about the amounts of phenotypic and genetic variation in dispersal characters that are expected both within and between populations, and the degree to which the expression of phenotypic characters affecting dispersal propensity should be sensitive to environmental conditions. The model also suggests novel mechanisms for coexistence between competing species in varying environment.