Field studies suggest that populations often go extinct following discrete changes in the environment. However, populations may avoid extinction by rapidly adapting to their altered environment. We used a stochastic finite-locus model to estimate the distance the optimal value of a quantitative trait could shift in a single step Δθc without causing more than 5% of the replicate populations to go extinct. We found that evolution increased the magnitude of Δθc by at least two phenotypic standard deviations and that such evolution could take place within 5–10 generations. Indeed (Δθc)2 increased approximately linearly with the logarithm of the initial population size and the rate of this increase was much greater when heritability was high or when stabilizing selection was weak. (Δθc)2 also increased approximately linearly with the logarithm of per capita fecundity. To our surprise there was no ‘demographic rescue’ effect from migration; a population augmented with migrants from a neighbouring population where environmental conditions were unchanged was always more likely to go extinct. The addition of mutation, more loci, density-dependence, or environmental stochasticity had only small effects on the outcome. We were able to compare our results for closed populations with density-independent population growth to those from an analytical model and found good agreement so long as the proportion of the offspring surviving selection in the initial generations was at least 1%.