Biological evolution and ecology are intimately linked, because the reproductive succes or “fitness” of an organism depends crucially on its ecosystem. The biotic and abiotic factors defining an ecosystem often have complex time- and space-dependent dynamics. Yet, most classical models of evolution describe homogeneous, fixed-size populations subjected to a constant selection pressure. An important challenge in evolutionary biology is therefore to understand the interaction between ecology and evolution. In this light, we study how spatial heterogeneities can drive evolution. To do so, we analyze stochastic models of populations evolving in patchy environments or environmental gradients, exploiting tools borrowed from statistical physics. First, we find that environmental heterogeneity can foster a mode of evolution that is impossible in uniform environments. In this mode, evolutionary adaptation is coupled to expansion of the species’ range, because the adaptation is driven solely by the benefit of an extended range. We argue that this mode of evolution could be relevant for important evolutionary processes such as the emergence of antibiotic resistance, the evolution of virulance, and viral evolution. Second, we explore how fluctuations in mutation rates as a result of environmental variability can affect rates of adaptation.