Modern snakes had an ancient forest-dwelling forebear with tiny ankles and toes that hunted at night and lived alongside the dinosaurs, say scientists.

Researchers came up with a portrait of the ancestral serpent after examining snake DNA and anatomy as well as information from the fossil record.

Daniel Field, from Yale University in the US, said: "Our analyses suggest that the most recent common ancestor of all living snakes would have already lost its forelimbs, but would still have had tiny hind limbs, with complete ankles and toes.

"It would have first evolved on land, instead of in the sea. Both of those insights resolve long-standing debates on the origin of snakes."

With more than 3,400 living species, snakes are one of the most recognisable groups of living vertebrates, yet little is known about how and where they first emerged.

The new study found that rather than making their first appearance in the Garden of Eden, snakes probably emerged in forested ecosystems in the southern hemisphere about 128.5 million years ago.

The common ancestor of modern snakes was likely to have been a non-constricting, nocturnal, stealth-hunting predator.

It would have seized its prey with needle-like teeth before swallowing it whole.

Co-author Allison Hsiang, also from Yale, said: "While snake origins have been debated for a long time, this is the first time these hypotheses have been tested thoroughly using cutting-edge methods.

"By analysing the genes, fossils and anatomy of 73 different snake and lizard species, both living and extinct, we've managed to generate the first comprehensive reconstruction of what the ancestral snake was like."

Senior study author Professor Jacques Gauthier, from Yale, said: "Primate brains, including those of humans, are hard-wired to attend to serpents, and with good reason.

"Our natural and adaptive attention to snakes makes the question of their evolutionary origin especially intriguing."

The research is reported in the journal BMC Evolutionary Biology.