It is a tenet of evolutionary biology that local adaptation is driven by natural selection, while it is hindered by gene flow. This is because random movements between populations disrupt the match between phenotype and the local environment. However, if individuals moved to the environments where they have higher ecological performance, movements between populations could facilitate local adaptation. Here we show that movements of individuals towards their phenotype-dependent optimal breeding areas rapidly result in adaptive population divergence. We manipulated local ecological performance in a wild population of Eurasian tree sparrows by creating an artificial ecological trait that gave differential access to a new food source. Individuals exhibited a very strong preference for the breeding sites where they had the highest ecological performance. This promoted higher reproductive success, local adaptation, assortative mating, and reproductive isolation with respect to the novel trait. Our results experimentally show how local adaptation can be achieved by directed movements of individuals, if they settle in the environment to which they are best adapted. Considering this mechanism of adaptation will improve our understanding of how populations and species adapt and diverge. This may be especially relevant for biodiversity management under global change, where organisms face rapid and novel environmental changes.