The evolutionary history of modern humans (Homo sapiens) is a messy one.  The story of our origin is further obfuscated by the fact that scientists have long had to rely on DNA extracted from extremely hard to find bones and teeth — often buried in inaccessible areas — to understand how we came to be and what our family trees look like.

In a study published Thursday in the journal Science, a team of researchers revealed it had successfully retrieved DNA of our extinct relatives, the Neandertals, and their Asian cousins, the Denisovans, from archaeological sites that did not contain any visible human remains. And they got this DNA, quite literally, from dirt — or, to be more precise, from sediments littering the floors of caves our ancestors are known to have lived in between 14,000 and 550,000 years ago.

ReadHave We Found A New Human Species?

“By retrieving hominin DNA from sediments, we can detect the presence of hominin groups at sites and in areas where this cannot be achieved with other methods,” study co-author Svante Pääbo, director of the evolutionary genetics department at the Max Planck Institute for Evolutionary Anthropology said in a statement. “This shows that DNA analyses of sediments are a very useful archaeological procedure, which may become routine in the future.”

Scientists have long known that several components of sediments can bind DNA — preserving a genetic record long after bones, teeth and other visible sources of DNA have decomposed or been carried off by scavengers. However, extracting these miniscule bits of genes from sediment samples is easier said than done, primarily because the genes of our human ancestors make up just one tiny fraction of the vast genetic debris deposited in caves over thousands of years.

“We therefore decided to investigate whether hominin DNA may survive in sediments at archaeological sites known to have been occupied by ancient hominins,” said lead researcher Matthias Meyer from the Max Planck Institute for Evolutionary Anthropology.

For their investigation, the researchers focused on seven archaeological sites in Belgium, Croatia, France, Russia and Spain. Most of these are places where no hominin teeth or bones have ever been found.

From the tiny amounts of sediments recovered, the researchers were then able to retrieve fragments of mitochondrial DNA belonging to twelve different mammalian species, including the woolly mammoth, the woolly rhinoceros, the cave bear and the cave hyena.

“From the preliminary results, we suspected that in most of our samples, DNA from other mammals was too abundant to detect small traces of human DNA,” Viviane Slon, a Ph.D. student at the Max Planck Institute in Leipzig and first author of the study, said in the statement. “We then switched strategies and started targeting specifically DNA fragments of human origin.”

This is when they struck gold. Nine samples from four sites were found to contain sufficient quantities of hominin DNA to merit further analysis, which revealed eight of them contained Neanderthal DNA and the other had DNA from Deniso­vans — a mysterious group of humans whose existence has only been gleaned from the DNA analysis of a few finger bones and teeth found in a Siberian cave.

“It’s a great breakthrough,” Chris Stringer, an anthropologist at London's Natural History Museum not involved in the study, told Science magazine. “Anyone who’s digging cave sites from the Pleistocene now should put [screening sediments for human DNA] on their list of things that they must do.”