The ancestors of modern humans interbred with Neanderthals and another extinct line of humans known as the Denisovans at least four times in the course of prehistory, according to an analysis of global genomes published Thursday in the journal Science.

The interbreeding may have given modern humans genes that bolstered immunity to pathogens, the authors concluded.

“This is yet another genetic nail in the coffin of our oversimplistic models of human evolution,” said Carles Lalueza-Fox, a research scientist at the Institute of Evolutionary Biology in Barcelona, Spain, who was not involved in the study.

The new study expands on a series of findings in recent years showing that the ancestors of modern humans once shared the planet with a surprising number of near relatives — lineages like the Neanderthals and Denisovans that became extinct tens of thousands of years ago.