The ancestors of the people who built Stonehenge travelled west across the Mediterranean before reaching Britain, a study has shown.
Researchers compared DNA extracted from Neolithic human remains found across Britain with that of people alive at the same time in Europe.
The Neolithic inhabitants were descended from populations originating in Anatolia (modern Turkey) that moved to Iberia before heading north.
They reached Britain in about 4,000BC.
Details have been published in the journal Nature Ecology & Evolution.
The migration to Britain was just one part of a general, massive expansion of people out of Anatolia in 6,000BC that introduced farming to Europe.
Before that, Europe was populated by small, travelling groups which hunted animals and gathered wild plants and shellfish.
One group of early farmers followed the river Danube up into Central Europe, but another group travelled west across the Mediterranean.
DNA reveals that Neolithic Britons were largely descended from groups who took the Mediterranean route, either hugging the coast or hopping from island-to-island on boats. Some British groups had a minor amount of ancestry from groups that followed the Danube route.
When the researchers analysed the DNA of early British farmers, they found they most closely resembled Neolithic people from Iberia (modern Spain and Portugal). These Iberian farmers were descended from people who had journeyed across the Mediterranean.
From Iberia, or somewhere close, the Mediterranean farmers travelled north through France. They might have entered Britain from the west, through Wales or south-west England. Indeed, radiocarbon dates suggest that Neolithic people arrived marginally earlier in the west, but this remains a topic for future work.
In addition to farming, the Neolithic migrants to Britain appear to have introduced the tradition of building monuments using large stones known as megaliths. Stonehenge in Wiltshire was part of this tradition.
Although Britain was inhabited by groups of "western hunter-gatherers" when the farmers arrived in about 4,000BC, DNA shows that the two groups did not mix very much at all.
The British hunter-gatherers were almost completely replaced by the Neolithic farmers, apart from one group in western Scotland, where the Neolithic inhabitants had elevated local ancestry. This could have come down to the farmer groups simply having greater numbers.
"We don't find any detectable evidence at all for the local British western hunter-gatherer ancestry in the Neolithic farmers after they arrive," said co-author Dr Tom Booth, a specialist in ancient DNA from the Natural History Museum in London.
"That doesn't mean they don't mix at all, it just means that maybe their population sizes were too small to have left any kind of genetic legacy."
Co-author Professor Mark Thomas, from UCL, said he also favoured "a numbers game explanation".
Professor Thomas said the Neolithic farmers had probably had to adapt their practices to different climatic conditions as they moved across Europe. But by the time they reached Britain they were already "tooled up" and well-prepared for growing crops in a north-west European climate.
The study also analysed DNA from these British hunter-gatherers. One of the skeletons analysed was that of Cheddar Man, whose skeletal remains have been dated to 7,100BC.
He was the subject of a reconstruction unveiled at the Natural History Museum last year. DNA suggests that, like most other European hunter-gatherers of the time, he had dark skin combined with blue eyes.
Genetic analysis shows that the Neolithic farmers, by contrast, were paler-skinned with brown eyes and black or dark-brown hair.
Towards the end of the Neolithic, in about 2,450BC, the descendants of the first farmers were themselves almost entirely replaced when a new population - called the Bell Beaker people - migrated from mainland Europe. So Britain saw two extreme genetic shifts in the space of a few thousand years.
Prof Thomas said that this later event happened after the Neolithic population had been in decline for some time, both in Britain and across Europe. He cautioned against simplistic explanations invoking conflict, and said the shifts ultimately came down to "economic" factors, about which lifestyles were best suited to exploit the landscape.
Dr Booth explained: "It's difficult to see whether the two [genetic shifts] could have anything in common - they're two very different kinds of change. There's speculation that they're to some extent population collapses. But the reasons suggested for those two collapses are different, so it could just be coincidence."
Follow Paul on Twitter.