Scientists generally accept that, millions of years ago, snakes evolved from lizards. What isn’t as clear, however, is exactly how these reptiles wiggled their way into a legless, elongated form. Evolutionary scientists have tried to figure this out by first determining where early snakes lived — the idea being that, once we know their ecological origins, we’ll have a better sense of how they became living noodles. Marine, terrestrial, and “fossorial” environments have been the best contenders.

Fossorial animals, like badgers and mole salamanders, lead a life of burrowing. And according to new research coming out of the University of Helsinki, the earliest snakes were fossorial as well, making the transition as they evolved from surface terrestrial-dwelling lizards. This contradicts previous theories, like the idea that snakes lost their legs while underwater and eventually crawled to land years later.

In a paper published Thursday in Nature Communications, the researchers explain that they came to their conclusion after comparing the shape and size of skulls belonging to 300 species of lizards and snakes. These skulls, representing both the embryonic and adult stages of the reptiles, comprised physical fossils borrowed from natural history museums and herpetologists as well as virtual specimens catalogued in digital morphology libraries.

snake skulls
Digital snake skulls.

The wide range of skull sources is one of the reasons the authors feel their study was able to be a success: The evolution of snakes has been historically difficult to study because well-preserved snake fossils are generally lacking. Among the few that exist, the oldest are between 140 to 170 million years old. In 2015, scientists from the University of Portsmouth found the first fossil of a four-legged snake, which, at the time, they said indicated that snakes evolved from burrowing lizards, not marine lizards.

snake embyro
Lizard and snake embryos.

The results of the new snake skull study adds to that theory: Skull structure, the researchers argue, predicts habitat, and their fossil samples demonstrate that the most recent common ancestor of snakes had a skull adapted for burrowing. Lizards, the researchers write, “could not have transitioned to snakes by any other evolutionary path than through fossoriality.”

After living an underground lifestyle, snakes later went on to colonize other habitats, both on land and in the sea (and, famously, sometimes in the air). Scientists believe that the lizard-to-snake transition was the result of ecological natural selection and gradual morphogenesis, the biological process that causes an organism to develop into its shape. In this case, the shape was legless and long.

“This set of results demonstrates the importance of the relationship between skull form, function, and development in the major ecological radiations of snakes to different habitats,” the researchers write, “and provides a new framework to understand the origin and evolutionary history of snakes.”