The farming way of life originated in the Near East some 11,000 years ago and had reached most of the European continent 5000 years later. However, the impact of the agricultural revolution on demography and patterns of genomic variation in Europe remains unknown. We obtained 249 million base pairs of genomic DNA from ~5000-year-old remains of three hunter-gatherers and one farmer excavated in Scandinavia and find that the farmer is genetically most similar to extant southern Europeans, contrasting sharply to the hunter-gatherers, whose distinct genetic signature is most similar to that of extant northern Europeans. Our results suggest that migration from southern Europe catalyzed the spread of agriculture and that admixture in the wake of this expansion eventually shaped the genomic landscape of modern-day Europe.