More than 250 million years ago, a reptile scampered around the earth with a long spiked tail and sharply pointed claws and scales as thick as a door. And the ferocious-looking creature had a ravenous appetite …

For plants.

That’s right. This animal, an ancient relative to today’s carnivorous crocodile, was, in fact, a vegetarian. It came as a bit of a surprise, too, to the scientists at the University of Utah who discovered it.

“It is sort of funny when you think about it,” said Keegan Melstrom, a graduate student and researcher at the U.’s Natural History Museum. “A vegetarian crocodile.”

It’s as if a tiny, furry mammal came face to face with the reptile during the Mesozoic Era, when dinosaurs walked about. And the crocodile was disinterested, Melstrom added, and chewed on some leaves instead. “It’s just really weird,” he said.

The breakthrough finding came in the summer of 2015. Melstrom, who had started graduate school in paleontology two years earlier, had wanted to study the extinct species of crocodyliforms — the lineage that leads to crocodiles, alligators and gharials.

He started reading papers on them and studied the illustrations. Melstrom noticed the shapes of teeth didn’t seem consistent. Why were they so different? Why were some pointed and others flat? What did it mean about what they ate?

“That’s a question we look at a lot, is what do the various extinct animals eat,” said Randall Irmis, Melstrom’s adviser and co-author on the research paper they published late last month.

Melstrom and Irmis created plastic models of the teeth with fossil forms and ran them through a computer program for two years. At first, the data it spit out didn’t mean anything.

“That’s how research goes,” Melstrom said with a laugh. “You kind of just smash your head against a computer for years until something works.”

Then, he was sitting in the lab in 2015, maybe June or July, listening to music. Suddenly, the program turned out an Excel spreadsheet. On first look, it appeared to have usable numbers.

Melstrom put them into a graph, and it showed what he expected: The teeth of some of the early crocodiles were complex with bumps and points. That meant they likely ate vegetables.

He remembers shouting throughout the research labs: “They’re herbivores! This is definitely an herbivore!”

The shape of teeth can say a lot about what an animal evolved to eat. Pearly whites that are uniformly sharp and conelike belong to carnivores (such as a dog), who use them to tear into meat. Species that eat primarily plants have more elaborate sizes and shapes because they must munch their food in their mouths before they swallow (think about a horse).

Humans are omnivores, eating plants and meat, so their teeth fall somewhere in between.

Melstrom’s program compared the ancient teeth to modern animals and assigned scores to place them on a scale. He found that at least three different times — but possibly as many as six — ancient crocodiles had evolved to fall on the plant diet side.

He studied 146 teeth from 16 species. One had three rows of cuspids “like seven different peaks in three mountain ranges in a row.”

“We suspected it,” Irmis said. “But this was the first time anyone had done a quantitative study. Crocodiles are finally getting their day in the sun. No pun intended there.”

All forms of the crocodile started out as carnivores. But at some point, a group branched off. Over time, about 100 million years, they started eating plants “as a tactic to survive,” Melstrom said. Their teeth adapted and eventually became smaller and duller.

This break in the lineage is substantial. And it appears in different places, as well as in environments that had mammals and some that didn’t. That suggests being an herbivore crocodile was successful, at least for a bit.

The species died off at the end of the Cretaceous Period, about 66 million years ago when all nonavian dinosaurs went extinct. “It was survival of the carnivores,” Melstrom joked.

It shows, though, that the evolution of the species was more complex than many think. Some say that crocodiles are living fossils. Their lineage suggest they went through a lot of change — including evolving to swim and eat plants.

Now, Melstrom will continue his study to find an explanation behind why the vegetarians didn’t make it.