Image copyright Voltaire Neto Image caption The reptile lived near lakes and rivers, feeding on smaller reptiles

A newly discovered 250-million-year-old fossil reptile from Brazil gives an "extraordinary" insight into life just before the dinosaurs appeared.

At the time, the world was recovering from a massive extinction that wiped out most living species.

The reptile, named Teyujagua or "fierce lizard", is the close relative of a group that gave rise to dinosaurs, crocodiles and birds.

The fossil is "beautiful" and fills an evolutionary gap, say scientists.

Dr Richard Butler from the University of Birmingham said the animal is a new species that has not been previously known.

"It's very close to the ancestry of a very important group of reptiles called archosauriforms," the co-researcher on the study, published in the journal Scientific Reports, told BBC News.

"It helps us understand how that group evolved."

'Beautiful skull'

Teyujagua paradoxa was a small crocodile-like animal that probably lived at the side of lakes, feeding on fish.

Image copyright Scientific Reports Image caption The skull of the reptile is exceptionally well preserved

The ancient reptile lived just after a mass extinction event 252 million years ago that was thought to have been triggered by a string of volcanic eruptions.

About 90% of living species were lost, creating a niche for other animals, such as Teyujagua, to flourish.

The reptile - and its close relatives the archosauriforms - became the dominant animals on land and eventually gave rise to the dinosaurs.

Dr Felipe Pinheiro, from Universidade Federal do Pampa, São Gabriel, Rio Grande do Sul, is among the scientists from three Brazilian universities who discovered the well-preserved fossil skull near the southern city of São Francisco de Assis.

"The discovery of Teyujagua was really exciting," he said.

"Ever since we saw that beautiful skull for the first time in the field, still mostly covered by rock, we knew we had something extraordinary in our hands.

"Back in the lab, after slowly exposing the bones, the fossil exceeded our expectations.

"It had a combination of features never seen before, indicating the unique position of Teyujagua in the evolutionary tree of an important group of vertebrates."

Teyujagua is different from other fossils from the same era.

Its anatomy is somewhere between that of more primitive reptiles and the archosauriforms, which include all dinosaurs and pterosaurs (flying reptiles), along with modern day birds and crocodiles.

Follow Helen on Twitter.