More than a hundred years after Grigg's influential analysis of species' borders, research into the causes of limits to species' ranges is more active than ever, fuelled by our need to understand their dynamics in the changing environments. Current predictions are either very specific, requiring measurements of many interrelated parameters, or make restrictive assumptions such as fixing the genetic variance or neglecting the two-dimensional spatial structure of most natural habitats. I show that the range margin can be understood based on just two measurable parameters: i) the fitness cost of dispersal -a measure of environmental heterogeneity -and ii) the strength of genetic drift, which reduces genetic diversity. Together, these two parameters define an expansion threshold : adaptation fails when the neighbourhood size is so small that genetic drift reduces diversity below the level required for adaptation to environmental heterogeneity. When the key parameters drop below this expansion threshold locally, a sharp range margin forms. When they drop below this threshold throughout the species' range, adaptation collapses everywhere, resulting in either extinction, or formation of a fragmented meta-population. Below the expansion threshold, increased dispersal is beneficial, because the reduction of both genetic and demographic stochasticity has a stronger effect than is its cost through increased maladaptation. Because the effects of dispersal differ fundamentally with dimension, the predictions are qualitatively different from those in a linear habitat. The expansion threshold provides a novel, theoretically justified and testable prediction for formation of the range margin and collapse of the species' range in two-dimensional habitats.