A mass migration of males transformed the genetic make-up of people in Spain during the Bronze Age, a study reveals.

DNA evidence shows the migrants streamed over the Pyrenees, replacing existing male lineages across the region within a space of 400 years.

It remains unclear whether there was a violent invasion or whether a male-centric social structure played an important role.

The result comes from the most extensive study of its kind.

Researchers reconstructed the population history of Iberia (modern Spain and Portugal) over 8,000 years - the biggest slice of time tackled by ancient DNA research.

Their study is published in Science journal.

They extracted and analysed DNA from 403 Iberians who lived between 6,000 BC and AD 1,600.

The Bronze Age male migrants traced some of their ancestry to Neolithic (Stone Age) farmers found throughout Europe - including Spain - while the rest of their genetic make-up was like that of people living at the time on the Russian steppe.

This steppe ancestry was introduced to Europe by nomadic herders who migrated west from Asia and the eastern fringes of Europe.

Ancient Britons 'replaced' by newcomers

Stone Age crisis
One of the triggers may have been a crisis that caused population numbers to plunge in Europe towards the end of the Neolithic period (which preceded the Bronze Age). Recent studies suggest plague might have played a role.

As the steppe people moved west, they picked up elements of culture from people they mixed with along the way. In Central Europe, one such mixed culture known as the Bell Beaker tradition formed. The Beakers and their descendants may have established highly stratified (unequal) societies in Europe, including Iberia - where they start turning up from 2,500BC.

The researchers looked at the Y chromosome - a package of DNA passed down more or less unchanged from father to son. It can be used to track male-line inheritance. By about 2,000BC, local Y chromosome lineages had been eliminated from the Iberian gene pool, in favour of those carried by the newcomers.

When the team analysed DNA from across the genome - the full complement of genetic material found in the nuclei of cells - they found that later Iberians traced 40% of their ancestry to the new population.

The newcomers - of Bell Beaker origin - brought innovations such as bronze-working (including the manufacture of bronze weapons) and were probably riding horses. These may have given them a military advantage over Stone Age farming societies, but also probably conferred higher social status on incoming males.

Patterns of inheritance
Co-author Iñigo Olalde, from Harvard Medical School, US, said: "It would be a mistake to jump to the conclusion that Iberian men were killed or forcibly displaced." He added: "The archaeological record gives no clear evidence of a burst of violence in this period."

Instead, the high social status of the newcomers may have been linked to greater reproductive success. "Their male descendants would have inherited the wealth and social status, and themselves also had much higher reproductive success," Dr Olalde told BBC News.

A system that emphasised male power and inheritance could have been key: "A patrilineal and possibly patriarchal social structure would further amplify the observed patterns, as possibly only the first-born son would inherit the clan's properties, whereas the other sons would move out and try to established their own clans, further spreading their Y lineages over new territories," he said.

An even more extreme pattern of replacement occurred at much the same time in Britain, where Beakers replaced 90% of the ancestry that was there before they arrived.

Fortified settlements
"At least in the east and the south-east, we see a change in the settlement patterns... which lasts until the arrival of the Romans," said co-author Dr Carles Lalueza-Fox, from the University of Barcelona.

In this region, the Iron Age Iberian culture established fortified settlements on high ground.

"The Iberians lived in hill settlements and were a violent society, structured along tribal lines. Something clearly changes the social structure that existed in the late Neolithic."

Looking at human remains from an earlier period, the study found that Stone Age hunter-gatherers who traced a significant percentage of their ancestry to some of Europe's earliest settlers, survived in southern Spain until the spread of farming 6,000 years ago.

The team also studied genome data from Moorish Spain (AD 711-1492), when parts of the peninsula were under the control of Muslim emirs of North African origin.

North African influence was present in Iberia from at least the Bronze Age. But the researchers found a dramatic shift in the genetic make-up of people from Moorish-controlled regions after the medieval "Reconquista", when Christian armies seized back control of the peninsula. The conquerors expelled many Muslims, although some were allowed to stay if they converted to Christianity.

While many Moorish individuals analysed in the study seem to have been a 50:50 mix of North African and Iberian ancestry, North African ancestry in the peninsula today averages just 5%.

Modern Iberians derive about 50% of their ancestry from Neolithic farmers, 25% from ancient hunter-gatherers, and 20% from the steppe people.