It's little secret that Neanderthals and our ancestors intimately enjoyed each other's company. The legacy of this occasional genetic mixing persists in the form of Neanderthal DNA that many modern humans continue to carry.

Exactly how this exchange benefited us has been a bit of a mystery. A new study argues that we have Neanderthals to thank for helping us cope with the viral tides we encountered as we marched around the globe.

Stanford University researchers have identified DNA sequences that evolved in our ancient cousins can produce antivirus proteins, which more than likely gave some human populations the edge they needed to survive.

"It made much more sense for modern humans to just borrow the already adapted genetic defences from Neanderthals rather than waiting for their own adaptive mutations to develop, which would have taken much more time," says evolutionary biologist David Enard, now at the University of Arizona.

It's not the first time we've gotten hints that interbreeding with other human species may have given our health a boost. A few years ago, the same lab traced another group of genes related to immunity to Neanderthal origins, laying the groundwork for ongoing research.

You could say the relationship status between our great-great grandparents and human populations that once inhabited Europe and Asia was kind of complicated.

We know there was significant mixing of gene pools at least twice in our shared histories, though just how those genes proceeded to spread through the global population is hard to say.

Roughly 1 percent of our genome's coding was written in Neanderthal populations. But this is a broad average – many families with African ancestry have zero, for instance, while other populations boast as much as 2 percent or more.

So the question is how much of this difference comes down to the random drift of DNA being passed on around the globe, and how much is due to natural selection giving those with Neanderthal genes an advantage?

To build a case one way or another, the Stanford researchers put together a list of just over 4,500 virus-interacting proteins (VIP) made by our genome.

These were all matched against a database of Neanderthal DNA that could be found in modern East Asian and European human populations, providing 152 VIP genes shared by both groups of human.

Interestingly, all of these VIP genes were of a variety that interacted with RNA viruses – pathogens that include influenza A, hepatitis C, and HIV.

This isn't to say these viruses were problems for ancient humans, but rather that similar RNA viruses were more than likely prevalent enough to shape our evolution.

The discovery supports a view of genetic exchange described as the 'poison-antidote' model.

As our ancestors slowly made their way across the Asian continent, they would have infrequently encountered pockets of other humans who potentially harboured all kinds of new nasties.

If you're familiar with the epidemics that followed the colonisations of the Western World, those encounters would have been a scaled-down preview; for newcomers to these pockets, a lack of evolved immunity was potentially disastrous.

Yet with the 'poison' could come an antidote - once these small populations interbred, the newbie humans would also inherit genes evolved to combat those particular pathogens.

"Modern humans and Neanderthals are so closely related that it really wasn't much of a genetic barrier for these viruses to jump," says Enard.

"But that closeness also meant that Neanderthals could pass on protections against those viruses to us."

Over time, as a mix of less useful Neanderthal genes fell out of our gene pool, those VIP genes stuck around, helping regional populations deal with their specific area's RNA viruses.

Different genes would have interacted with different pathogens, explaining why the same kinds of Neanderthal genes aren't found in equal numbers in Europe and Asia.

Working backwards from these genes, it could even be possible to find hints of viruses that once plagued Neanderthals – not unlike using fossilised footprints as signs of extinct animals.

"Our method is similarly indirect: because we know which genes interact with which viruses, we can infer the types of viruses responsible for ancient disease outbreaks," says Enard.

This research was published in Cell.