A study of DNA from ancient human bones has helped unlock the secrets of Europe's Ice Age inhabitants.
Researchers analysed the genomes of 51 individuals who lived between 45,000 years ago and 7,000 years ago.
The results reveal details about the biology of these early inhabitants, such as skin and eye colour, and how different populations were related.
It also shows that Neanderthal ancestry in Europeans has been shrinking over time, perhaps due to natural selection.
The study in Nature journal shines a torchlight over some 40,000 years of prehistory, showing that ancient patterns of migration were just as complex as those in more recent times.
Some of the earliest arrivals on the continent contributed little to later populations. But between 37,000 years ago and 14,000 years ago, different groups of Europeans were descended from a single founder population.
The fortunes of these human hunting groups were often linked to changes in the climate.
Co-author Prof David Reich, from Harvard Medical School in Boston, US, said the 51 ancient individuals comprised "a pretty substantial fraction of the known human skeletons in this period".
He told BBC News: "Because we've studied so many ancient humans from Europe from the beginning of the modern human occupation, we're able to form a picture of how populations transformed over time."
Prof Reich, Svante Paabo from the Max Planck Institute for Evolutionary Anthropology in Leipzig, Germany, and others found evidence that people belonging to one of Europe's most important Ice Age cultures - the Aurignacian - were displaced between 34,000 and 26,000 years ago by another group of humans called the Gravettians.
After 14,000 years ago, Europeans became more closely related to populations from the Middle East, the Caucasus and Turkey. This happens to coincide with the first major warming period at the end of the Ice Age and could reflect an expansion of people from the South-East.
"We see multiple, huge movements of people displacing previous ones," said Prof Reich.
"During this first four-fifths of modern human history in Europe, history is just as complicated as it is during the last fifth that we know so much more about."
Research on that last fifth of population history has revealed that mass movements of people in the Neolithic period (from 7,000 years ago) and the Bronze Age (5,000 years ago) transformed the genetic landscape of Europe.
Analysis of genes carried by Ice Age Europeans shows, among other things, that they had dark complexions and brown eyes. Only after 14,000 years ago did blue eyes begin to spread, and pale skin only appeared across much of the continent after 7,000 years ago - borne by early farmers from the Near East.
Early European populations possessed more Neanderthal ancestry than present-day people, consistent with the idea that much of the DNA we inherited from the Neanderthals had harmful effects. Scientists think this inheritance was progressively lost via natural selection.
What seems clear is that most modern populations offer only hazy glimpses into the past, because their genetics are shaped by relatively recent patterns of migration.
Insights like those from this study have only been made possible by dramatic progress in the last two decades on techniques for analysing degraded DNA from ancient remains.
"A lot of amazing work was done [previously] to develop and use sophisticated methods to forensically piece apart patterns based on populations today," Prof Reich told BBC News.
"But it's a little bit like trying to dissect the ingredients that go into the batter of a cake from the mixed up batter... how much flour, how much egg, how much sugar, how much butter.
"You could do it if you worked really hard and knew the chemistry. But what if you could go back to when they were adding in the butter, adding in the sugar, adding in the flour and measure how much was added in each time."
Meet the ancestors
The Aurignacians: A 35,000-year-old male from Goyet, Belgium, belonged to a distinctive branch of the Ice Age population. DNA was extracted from the upper arm bone of the hunter, who was associated with the Aurignacian archaeological culture.
The Gravettians: This ancestral group displaced the Aurignacians to dominate much of Europe from 34,000 to 26,000 years ago. Though they carried distinct genetic signatures, the Gravettians and Aurignacians were descended from the same ancient founder population.
The Magdalenians: The Aurignacian genetic signature disappeared from much of Europe when the Gravettians arrived. But it resurfaced 15,000 years later in the "Red Lady of El Mirón Cave" from northern Spain (pictured). This tall, robust woman was a member of the Magdalenian archaeological culture, which expanded north as the ice sheets melted.
The Villabruna cluster: From about 14,000 years ago, the gene pools of Europe and the Middle East draw closer together - perhaps reflecting an expansion of people from the south-east. This genetic cluster is named after a male hunter from Villabruna, Italy, who had dark skin and blue eyes.
Follow Paul on Twitter.