Woolly mammoths met their end nearly 4,000 years ago after five million years of existence, and scientists claim they now know how these massive creatures vanished.

The extinction of woolly mammoths began when the icebergs melted, according to an analysis of ancient environmental DNA. The environment became too wet for them to thrive because the vegetation they ate was practically wiped out.

Environmental plant and animal remains, including urine, feces, and skin cells, were studied in soil samples collected over a 20-year period from sites in the Arctic where mammoth remains were discovered.

Scientists no longer need to rely on DNA samples from bones or teeth to accumulate enough genetic material to reconstruct an ancient DNA profile, thanks to advances in technology.

Eske Willerslev, a fellow of St John's College, University of Cambridge, and director of The Lundbeck Foundation GeoGenetics Centre, University of Copenhagen, oversaw the 10-year research project.

"Humans have been blamed because the animals had survived for millions of years without climate change killing them off before, but when they lived alongside humans they didn't last long and we were accused of hunting them to death," Willerslev said in a statement.

The modern elephants' ancestors lived with early humans and were a mainstay of their diet.

The remains of the hairy beasts were used to create shelters, harpoons were cut from their massive tusks, and cave walls are covered in artwork depicting them.

Research suggests the oldest known musical instrument, a flute, was made of mammoth bone around 30,000 years ago.

"We have finally been able to prove that it was not just the climate changing that was the problem, but the speed of it that was the final nail in the coffin - they were not able to adapt quickly enough when the landscape dramatically transformed and their food became scarce.

The most recent Ice Age, known as the Pleistocene, ended 12,000 years ago when glaciers began to melt and mammoth herds' traveling range narrowed.

Mammoths were believed to have gone extinct around this time, but scientists have discovered that they actually lasted past the Ice Age in various parts of the Arctic and into the Holocene - the period we are currently living in - far longer than scientists expected.

"This is a stark lesson from history and shows how unpredictable climate change is - once something is lost, there is no going back," Willerslev concluded.

The authors noted that precipitation was the cause of the extinction of woolly mammoths due to plant changes, and that the change occurred so swiftly that they were unable to adapt and evolve in time to survive.

The study is published in Nature.