About 70,000 years ago, Homo sapiens moved out of Africa and into Eurasia. There, they encountered the Neanderthals, another member of the ancient Homo family that got to Eurasia hundreds of thousands of years before. We don’t know much about their interactions, whether they warred or allied, but we know one thing for certain: they had sex. And according to a new study in Cell, in these trysts with Sapiens they not only swapped spit but also exchanged life-saving genetic adaptations.

The genetic gift the Neanderthals passed down to their human-hybrid children is the result of thousands of years of painful natural selection. In a study published Thursday, scientists from the University of Arizona and Stanford University explain that while modern humans were still in Africa, Neanderthals were up in Eurasia battling new pathogens. By the time humans hooked up with them, the genomes of the Neanderthals contained adaptive mutations that enabled them to fight off viruses. All of the Neanderthals that didn’t have these mutations didn’t survive infection with those viruses, and so their genes were slowly removed from the gene pool.

When modern humans came along and interbred with the Neanderthals — they could do so because they shared a common ancestor that lived some 500,000 to one million years ago — their offspring inherited some of those protective genetic mutations and survive.

“Neanderthal genetic material was like a protective antidote because Neanderthals had likely been infected for a long time by the same viruses that were now harmful to modern humans,” explains study co-author David Enard, Ph.D. to Inverse. “This long exposure means that Neanderthals had plenty of time to adapt against these viruses before modern humans showed up.”

Enard and co-author Dmitir Petrov, Ph.D., posit, however, that things weren’t all genetic-adaption roses when these two species of humans met up. Enard and Petrov say that what happened here was a “poison-antidote” model of gene swapping. Essentially, when Neanderthals and modern humans met, they very likely infected each other with the pathogens from their respective environments. That’s the poison part. The antidote, meanwhile, was the result of their sexual encounters.

“These viruses were old news to Neanderthals, but were a new sudden challenge for modern humans,” explains Enard. “Then, modern humans took the fast-track route for adaptation against these new viruses simply by borrowing the pre-adapted genetic material from Neanderthals. Instead of ‘reinventing the genetic wheel,’ we just borrowed it from the Neanderthals.”

The scientists came to this conclusion after compiling a list of more than 4,500 genes in modern humans known to be involved in virus defense and comparing it against a database of sequenced Neanderthal genes. They found that 152 fragments of modern human genes were also present in the Neanderthal genome. Today, those 152 genes, which the team believes we inherited from the Neanderthals, interact with modern day RNA viruses like HIV, influenza A, and hepatitis C.

The implication is that Neanderthal genes were conserved because they once helped our ancestors fight off the ancient RNA viruses they encountered in Eurasia. Importantly, the gene fragments are only present in the genomes of modern Europeans, so it remains to be seen how or whether the Neanderthal trysts that led to modern Asians influenced their survival.

What we do know from previous studies is that Neanderthal DNA passed down other, less beneficial inherited traits, such as a greater likelihood of developing depression or becoming addicted to cigarettes.

Neanderthal DNA influences particular traits in humans. Deborah Brewington, Vanderbilt University

The genes discovered in the new paper, unfortunately, don’t actually protect against modern viruses, says Enard. Those genes interact with but don’t necessarily protect against modern RNA viruses, even though they probably protected our ancestors against ancient viruses. If they were useful against modern viruses like the flu, says Enard, we probably wouldn’t have so many people dying of viral infections every year.

“The evolution against viruses is an arms race, which means it is a never-ending process where, as soon as we are done adapting against a virus during our evolution, we had to start adapting against new viruses that had just jumped the species barrier,” explains Enard. “It was very sobering realization for Dr. Petrov and I that our work likely implies that humans had to adapt to hundreds, if not thousands of different harmful viruses over million years of evolution.”

We don’t have ancient humans that we can have sex with and inherit genetic adaptions from anymore. But we do have something better — easily available and proven to work vaccines.

“The unfathomable amount of deaths through viral infections that it took humans to eventually adapt,” says Enard, “is a pressing reminder of the absolute and urgent necessity of vaccination.”