Did mortal enemies cats and dogs ever live harmoniously? Around nine million years ago it appears they did, sharing food and space in the wild.

Fossilised fangs from saber-toothed cats and bear dogs show how the two species shared the same space and hunted the same prey.

Researchers at the University of Michigan and the Museo Nacional de Ciencias Naturales in Madrid found the tooth enamel of two species of saber-toothed cats and one of a bear dog; which had dog like teeth and a bear-like body.

The teeth were found in geological pits near Madrid. They show how all three species lived together in one space.

Researchers think the Promegantereon ogygia - a leopard-sized sabre-toothed cat - would avoid the Machairodus aphanistus, which was the same size as a lion and lived in trees. They both ate horses and wild boar. The bear dog (Amphicyonidae) would then hunt antelope in the same area.

Sabre-toothed cat
Sabre-toothed cats lived on horses and wild boar, scientists say.

Study author Soledad Domingo said: "These three animals were sympatric - they inhabited the same geographic area at the same time. What they did to coexist was to avoid each other and partition the resources.

The research site is one of nine ancient pits that has an abundance of meat-eating mammal bones. "These sites offer a unique window to understand life in the past," Domingo said.

Scientists sampled the teeth of 69 specimens, including 29 saber-toothed cats and bear dogs and were able to work out their diet from the carbon from the tooth enamel.

"This would be the same in your tooth enamel today. If we sampled them, we could have an idea of what you eat. It's a signature that remains through time," he said.

From understanding what these animals ate, they could work out what their habitat was like. It is thought all three lived in a woodland area that had patches of grassland.

Catherine Badgley, co-author of the study, said: "The three largest mammalian predators captured prey in different portions of the habitat, as do coexisting large predators today.

"So even though none of the species in this nine million-year-old ecosystem are still alive today - some of their descendants are - we found evidence for similar ecological interactions as in modern ecosystems."

Both saber-toothed cats and bear dogs existed for over 40 million years.

Bear dog
A bear dog skeleton. It is now thought it shared its habitat with cats.