An ancient African genome has been sequenced for the first time.
Researchers extracted DNA from a 4,500-year-old skull that was discovered in the highlands of Ethiopia.
A comparison with genetic material from today's Africans reveals how our ancient ancestors mixed and moved around the continents.
The findings, published in the journal Science, suggests that about 3,000 years ago there was a huge wave of migration from Eurasia into Africa.
This has left a genetic legacy, and the scientists believe up to 25% of the DNA of modern Africans can be traced back to this event.
"Every single population for which we have data in Africa has a sizeable component of Eurasian ancestry," said Dr Andrea Manica, from the University of Cambridge, who carried out the research.
Ancient genomes have been sequenced from around the world, but Africa has proved difficult because hot and humid conditions can destroy fragile DNA.
However, the 4,500-year-old remains of this hunter gatherer, known as Mota man, were found in a cave and were well preserved.
Importantly, a bone that is situated just below the ear, called the petrous, was intact.
Dr Manica, speaking to Science in Action on the BBC World Service, said: "The petrous bone is really hard and does a really good job of preventing bacteria getting in and degrading this DNA.
"What we were able to get is some very high quality undamaged DNA from which we could reconstruct the whole genome of the individual.
"We have the complete blueprint, every single gene, every single bit of information that made this individual that lived 4,500 years ago in Ethiopia."
The genome revealed that Mota man had purely African DNA, his ancestors had never moved from Africa.
But the comparison of this with modern African genomes highlighted that about 1,500 years after his death, the make-up of the continent had changed.
Genetic studies have shown that after the great migration out of Africa, which happened about 60,000 years ago, some people later returned to the continent.
But this study shows that about 3,000 years ago there was a much larger migration than had been thought.
The Neolithic farmers from western Eurasia who, about 8,000 years ago, brought agriculture to Europe then began to return to Africa.
"We know now that they probably corresponded to a quarter of the people that already lived in East Africa (at that time). It was a major backflow, a very sizeable movement of people," said Dr Manica.
It is unclear what caused this move - potentially changes happening in the Egyptian empire - but it has left a genetic legacy.
"Quite remarkably, we see in Ethiopia about 20% - so a fifth - of the genome of people living there right now is actually of Eurasian origin, it actually comes from these farmers," explained Dr Manica.
"But it goes further than that, because if you go to the corners of Africa, all the way to West Africa or South Africa, even populations that we really thought were purely African have 5-6% of their genome that dates back to these western Eurasian farmers."
The Eurasians' return also introduced some extra genetic material to Africa.
The genes their ancestors had picked up from interbreeding with Neanderthals were then passed to Africans, and can still be seen today.
Commenting on the research, Dr Carles Lalueza-Fox, from the Institute of Evolutionary Biology in Barcelona, Spain, said: "What is nice is that it places in time the origin of the Eurasian backflow into Africa already detected some years ago from modern genome data, and it turns out to be the farming.
"Once again, like in the case of Europe where we see dramatic genomic turnover, the spread of agriculture has had a huge impact even in a continent where large groups continued to be hunter gatherers.
"And it is also interesting to discover now that even sub-Saharan Africans have a bit (0.3-0.7%) of Neanderthal ancestry."
Prof David Reich, from Harvard Medical School in the US, added: "The claim that all sub-Saharan Africans today have a substantial amount of ancestry due to back-to-Africa migrations is quite interesting, and while I won't be 100% convinced until I look at the data myself, I think the analyses seem careful and thoughtful.
"While previous studies have documented substantial West Eurasian ancestry in some sub-Saharan African populations, including Nigerians and KhoeSan from southern Africa, if the findings of this paper are right, they are important because they extend these claims to populations that were previously thought to have little or no West Eurasian ancestry, for example Mbuti hunter gatherers from central/east Africa."