A million-year-long period of extreme volcanic activity most likely paved the way for the dawn of the dinosaurs, a study suggests.
Scientists have analysed ancient rocks and have found traces of emissions from huge volcanic eruptions that happened about 200 million years ago.
This would have led to one of the largest mass extinctions on record, enabling dinosaurs to become dominant.
The study is published in the journal PNAS.
Lead author Lawrence Percival, from the Earth sciences department at Oxford University, said: "The dinosaurs were able to exploit those ecological niches that were left vacant by the extinction."
The researchers looked at volcanic rocks from four continents that date to this turbulent time.
A previous study assessed how levels of carbon fluctuated in the rocks, which is linked to rises of carbon dioxide from volcanic eruptions.
But this research looked at a different fingerprint for volcanic activity: mercury.
When volcanoes erupt, they emit traces of mercury in the plumes of gas that rise into the sky. This then spreads throughout the atmosphere before being deposited in sediments on the ground, where it remains for millions of years.
"If you can see a big spike in mercury in those sediments, you can infer there is volcanism happening at that exact time," explained Mr Percival.
"And that's what we see at the time of this extinction."
The researchers found evidence for huge pulses of volcanic activity that would have continued for about a million years.
Prof Tamsin Mather from Oxford University said: "You get these fissures, these cracks opening up in the Earth's crust, and probably some fire fountains, and also lava flows opening up.
"You probably had different areas active at different times during the million years. And you likely get eruptive periods going on for a decade or so with enormous volumes of magma coming to the surface and gases as well."
Anything living in the immediate vicinity of the eruptions would have fared badly. But creatures living far away would also have been in trouble: the repeated eruptions would have had a devastating impact on the wider environment, blocking out the Sun and leading to rising levels of carbon dioxide.
This would have triggered a major mass extinction: animals including vast crocodile-like creatures and reptilian-looking mammals and early amphibians were wiped out.
However, early dinosaurs from that period clung on, although researchers are not sure how they survived the hellish conditions.
But once the volcanoes had simmered down, few of their competitors were left, allowing the age of the dinosaurs to begin.
The researchers now want to use mercury to look at other periods of ancient volcanic activity.
Prof Mather said: "I think what's really exciting is that we are talking about an episode of volcanism that happened 200 million years ago, and these mercury records in the sediments are allowing us to say new things about volcanism that happened that far back in deep Earth time.
"This is a new and powerful tool that will really allow us to understand more about the evolution of our planet and how it's come to be how it is today."
Follow Rebecca on Twitter: @BBCMorelle