The DNA of extinct humans can be retrieved from sediments in caves - even in the absence of skeletal remains.
Researchers found the genetic material in sediment samples collected from seven archaeological sites.
The remains of ancient humans are often scarce, so the new findings could help scientists learn the identity of inhabitants at sites where only artefacts have been found.
The results are described in Science.
Antonio Rosas, a scientist at Spain's Natural Science Museum in Madrid, said: "This work represents an enormous scientific breakthrough.
"We can now tell which species of hominid occupied a cave and on which particular stratigraphic level, even when no bone or skeletal remains are present."
"We know that several components of sediments can bind DNA," said lead researcher Matthias Meyer of the Max Planck Institute for Evolutionary Anthropology in Leipzig, Germany.
"We therefore decided to investigate whether hominin DNA may survive in sediments at archaeological sites known to have been occupied by ancient hominins."
The team collaborated with researchers excavating at seven dig sites in Belgium, Croatia, France, Russia and Spain.
They collected sediment samples covering a time span from 14,000 to 550,000 years ago.
Back in the lab, they fished out tiny fragments of mitochondrial DNA (mtDNA) - genetic material from the mitochondria, which act as the "powerhouses" of biological cells. Even sediment samples that had been stored at room temperature for years yielded DNA.
Dr Meyer and his team members were able to identify the DNA of various animals belonging to 12 mammalian families, including extinct species such as the woolly mammoth, woolly rhinoceros, cave bear and cave hyena.
The scientists looked specifically for DNA from ancient humans in the samples.
"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," said co-author Viviane Slon, from the Max Planck Institute in Leipzig, Germany.
"We then switched strategies and started targeting specifically DNA fragments of human origin."
The team members managed to retrieve DNA from Neanderthals in the cave sediments of four archaeological sites, including in layers where no human skeletal remains have been discovered.
In addition, they found new samples of Denisovan DNA in sediments from Denisova Cave in Russia.
"The technique could increase the sample size of the Neanderthal and Denisovan mitochondrial genomes, which until now were limited by the number of preserved remains," co-author Spanish National Research Council scientist Carles Lalueza-Fox told the AFP news agency.
"And it will probably be possible to even recover substantial parts of nuclear genomes."
Svante Pääbo, director of the Evolutionary Genetics department at the Max Planck Institute for Evolutionary Anthropology, commented: "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.
"This shows that DNA analyses of sediments are a very useful archaeological procedure, which may become routine in the future."