Dinosaurs and flying pterosaurs are well known for their colossal size but they may be related to a species small enough to sit on your hand.

A new 4in tall species called Kongonaphon kely has been discovered by scientists in Madagascar, which they believe could be ancient relatives to the larger reptiles that followed.

The creatures – first unearthed in 1998 among hundreds of fossils – are thought to have lived around 237 million years ago.

“There’s a general perception of dinosaurs as being giants, but this new animal is very close to the divergence of dinosaurs and pterosaurs, and it’s shockingly small,” said Christian Kammerer, a research curator in paleontology at the North Carolina Museum of Natural Sciences.

Researchers have analysed the “tiny bug slayer” fossils and believe they could well be ancestors to dinosaurs and pterosaurs, which both belong to the Ornithodira group.

Little is known about this lineage because few specimens have been found.

“This fossil site in south-western Madagascar from a poorly known time interval globally has produced some amazing fossils, and this tiny specimen was jumbled in among the hundreds we’ve collected from the site over the years,” said John Flynn, a curator of fossil mammals at the American Museum of Natural History Frick.

“It took some time before we could focus on these bones, but once we did, it was clear we had something unique and worth a closer look.

“This is a great case for why field discoveries – combined with modern technology to analyse the fossils recovered – are still so important.”

Scientists hope the findings could also help to explain the origins of flight in pterosaurs, as well as the presence of “fuzz” on the skin of both pterosaurs and dinosaurs.

“Recent discoveries like Kongonaphon have given us a much better understanding of the early evolution of ornithodirans,” Mr Kammerer added.

“Analysing changes in body size throughout archosaur evolution, we found compelling evidence that it decreased sharply early in the history of the dinosaur-pterosaur lineage.”

The findings are published in the Proceedings of the National Academy of Sciences journal.