“We were actually able to not only say, ‘Yes, modern humans and Neanderthals exchanged viruses,’” said David Enard, an evolutionary biologist at the University of Arizona and co-author of the new paper, published in the journal Cell. “We are able to start saying something about which types of viruses were involved.”

But if Neanderthals made us sick, they also helped keep us well. Some of the genes inherited from them through interbreeding also protected our ancestors from these infections, just as they protected the Neanderthals.

Lluis Quintana-Murci, a geneticist at the Pasteur Institute in Paris who was not involved in the new research, said that until now, scientists had not dreamed of getting such a glimpse at the distant medical history of our species.

“Five years ago, we would never have imagined that,” he said.

Our immune cells kill off viruses with an arsenal of weapons, such as antibodies and signals that cause infected cells to commit suicide. But Dr. Enard began his research by wondering if humans have evolved other ways to avoid getting infected.

Viruses can’t replicate on their own. They appropriate proteins inside our cells to do the heavy lifting, copying viral genes and building new shells to put them in. If those proteins were to change shape, however, it should become harder for viruses to use them to multiply.