Image copyright S. ENTRESSANGLE/E. DAYNES/SCIENCE PHOTO LIBRARY

We may owe our ability to fight disease to our extinct relatives - the Neanderthals and Denisovans.

According to a pair of scientific studies, key genes in the immune system come from our ancient "cousins".

The findings, which appear in The American Journal of Human Genetics, suggest we have Neanderthals to thank for being able to fight off pathogens.

But interbreeding may have had a downside, as the same genes may have made us more prone to allergies.

Modern-day people can trace their ancestry to a small population that emerged from Africa about 60,000 years ago.

As the African humans spread out across the world, they came into contact with other ancient humans based in Europe and Western Asia.

Genetic evidence suggests that these different "tribes" interbred, with part of the genome of Neanderthals still present in humans alive today.

About 1% to 6% of the modern Eurasian human genome seems to come from Neanderthals and Denisovans - another extinct member of the human family.

Scientists in Germany analysed the genes of both modern humans and our ancient relatives to find the source of changes in our immune system's genetic blueprints.

Image copyright RIA NOVOSTI/SCIENCE PHOTO LIBRARY Image caption Archaeologist cataloguing finds from the Denisova Cave, Siberia, Russia

They found some of the fragments of Neanderthal DNA in humans alive today play a key role in the immune system as the front line of defence against pathogens such as bacteria, fungi and parasites.

"The evidence suggests that this genetic region contributes to the immune system of modern day humans," Dr Michael Dannemann of the Max Planck Institute for Evolutionary Anthropology in Leipzig, Germany, told BBC News.

"At some point in history it might have been an advantage to have these Neanderthal genes in terms of fighting off infections or lethal pathogens from 10,000 years ago.

"It could also still be an advantage today but this is difficult to pinpoint."

Dr Danneman, a co-researcher on one of the papers, said this inheritance from the Neanderthals could also have left some people more prone to allergies - because of the effect on the immune system - although this needs further investigation in the laboratory.

Big surprise

A second group of researchers - in France and the US - independently analysed genetic data on modern people from the 1000 Genomes project together with the genome sequences of ancient humans.

They came to similar conclusions - that a particular cluster of important human immune genes come from Neanderthals and Denisovans.

Dr Lluis Quintana-Murci of the Unit of Human Evolutionary Genetics, Institut Pasteur, Paris, said the findings came as a big surprise.

"Our big surprise was to find that this gene region has such a high Neanderthal ancestry because this region has been shown to have a major biological relevance in host survival against pathogens," he said.

"Maybe we should thank Neanderthals for having given us diversity in innate immunity to survive better against pathogens."

Follow Helen on Twitter.