While most modern crocodiles live in freshwater habitats and feed on mammals and fish, their ancient relatives were extremely diverse.

Some were built for running around like dogs on land and others adapted to life in the open ocean, imitating the feeding behaviour of today's killer whales.

For the first time, the study has found how the jaws of ancient crocodiles evolved to enable these animals to survive in vastly different environments, all whilst living alongside the dinosaurs 235 to 65 million years ago.

"The ancestors of today's crocodiles have a fascinating history that is relatively unknown compared to their dinosaur counterparts. They were very different creatures to the ones we are familiar with today, much more diverse and, as this research shows, their ability to adapt was quite remarkable," Tom Stubbs, who led the study at the University of Bristol, said.

"Their evolution and anatomical variation during the Mesozoic Era was exceptional. They evolved lifestyles and feeding ecologies unlike anything seen today," Stubbs said.

The team examined variation in the morphology (shape) and biomechanics (function) of the lower jaws in over 100 ancient crocodiles, using a unique combination of numerical methods.

"We were curious how extinction events and adaptations to extreme environments during the Mesozoic - a period covering over 170 million years - impacted the feeding systems of ancient crocodiles and to do this we focused our efforts on the main food processing bone, the lower jaw," Dr Stephanie Pierce, from The Royal Veterinary College, said.

By analyzing variation in the lower jaw, the researchers provide novel insights into how the feeding systems of ancient crocodiles evolved as the group recovered from the devastating end-Triassic extinction event and subsequently responded to the distribution of ecological resources, such as habitat and foodstuff.

For the first time, the research has shown that, following the end-Triassic extinction, ancient crocodiles invaded the Jurassic seas and evolved jaws built primarily for hydrodynamic efficiency to capture agile prey, such as fish.

However, only a small range of elongate lower jaw shapes were suitable in Jurassic marine environments.

"Our results show that the ability to exploit a variety of different food resources and habitats, by evolving many different jaw shapes, was crucial to recovering from the end-Triassic extinction and most likely contributed to the success of Mesozoic crocodiles living in the shadow of the dinosaurs," Pierce added.

The study was published in the journal Proceedings of the Royal Society B.