We sequenced the genomes of a similar to 7,000-year-old farmer from Germany and eight similar to 8,000-year-old hunter-gatherers from Luxembourg and Sweden. We analysed these and other ancient genomes(1-4) with 2,345 contemporary humans to show that most present-day Europeans derive from at least three highly differentiated populations: west European hunter-gatherers, who contributed ancestry to all Europeans but not to Near Easterners; ancient north Eurasians related to Upper Palaeolithic Siberians(3), who contributed to both Europeans and Near Easterners; and early European farmers, who were mainly of Near Eastern origin but also harboured west European hunter-gatherer related ancestry. We model these populations' deep relationships and show that early European farmers had similar to 44% ancestry from a 'basal Eurasian' population that split before the diversification of other non-African lineages.