The fossil record of snakes is relatively poor because snake skeletons are typically small and fragile, making fossilization uncommon. However 150 million-year-old specimens, readily identifiable as snakes, yet with lizard-like skeletal structures, have been uncovered in South America and Africa. There is consensus, on the basis of comparative anatomy, that snakes descended from lizards. Fossil evidence suggests that snakes may have evolved from burrowing lizards, such as the varanids or a similar group during the Cretaceous Period. An early fossil snake, Najash rionegrina, was a two-legged burrowing animal with a sacrum, and was fully terrestrial. One extant analog of these putative ancestors is the earless monitor Lanthanotus of Borneo, although it also is semi-aquatic. Subterranean forms evolved bodies that were streamlined for burrowing and lost their limbs. According to this hypothesis, features such as the transparent, fused eyelids (brille) and loss of external ears evolved to cope with fossorial difficulies such as scratched corneas and dirt in the ears. Some primitive snakes are known to have possessed hindlimbs, but their pelvic bones lack a direct connection to the vertebrae. These include fossil species like Haasiophis, Pachyrhachis and Eupodophis, which are slightly older than Najash.
Primitive groups among the modern snakes, pythons and boas, have vestigial hind limbs; tiny, clawed digits known as anal spurs which are used to grasp during mating.Leptotyphlopidae and Typhlopidae are other groups where remnants of the pelvic girdle are present, sometimes appearing as horny projections when visible. The frontal limbs are non-existent in all snakes and this loss is associated with the evolution of the Hox genes controlling limb morphogenesis. The axial skeleton of the snakes' common ancestor, like most other tetrapods had regional specializations consisting of cervical (neck), thoracic (chest), lumbar (lower back), sacral (pelvic) and caudal (tail) vertebrae. The Hox gene expression in the axial skeleton responsible for the development of the thorax became dominant early in snake evolution and as a result, the vertebrae anterior to the hindlimb buds (when present) all have the same thoracic-like identity (except from the atlas, axis and one to three neck vertebrae), making most of the snake's skeleton being composed of an extremely extended thorax. Ribs are found exclusively on the thoracic vertebrae. The neck, lumbar and pelvic vertebrae are very reduced in number (only two to ten lumbar and pelvic vertebrae are still present), while only a short tail remains of the caudal vertebrae, although the tail is still long enough to be of good use in many species, and is modified in some aquatic and tree dwelling species.
An alternative hypothesis, based on morphology, suggests that the ancestors of snakes were related to mosasaurs — extinct aquatic reptiles from the Cretaceous — which in turn are thought to have derived from varanid lizards. Under this hypothesis, the fused, transparent eyelids of snakes are thought to have evolved to combat marine conditions (corneal water-loss through osmosis), while the external ears were lost through disuse in an aquatic environment, ultimately leading to an animal similar in appearance to sea snakes of today. In the Late Cretaceous, snakes re-colonized land to appear as they are today. Fossil snake remains are known from early Late Cretaceous marine sediments, which is consistent with this hypothesis, particularly as they are older than the terrestrial Najash rionegrina. Similar skull structure; reduced/absent limbs; and other anatomical features found in both mosasaurs and snakes lead to a positive cladistical correlation, although some of these features are shared with varanids. In recent years, genetic studies have indicated that snakes are not as closely related to monitor lizards as it was once believed, and therefore not to mosasaurs, the proposed ancestor in the aquatic scenario of their evolution. However, there is more evidence linking mosasaurs to snakes than to varanids. Fragmentary remains that have been found from the Jurassic and Early Cretaceous indicate deeper fossil records for these groups, which may eventually refute either hypothesis.
The great diversity of modern snakes appeared in the Paleocene, correlating with the adaptive radiation of mammals following the extinction of the non-avian dinosaurs. One of the more common groups today, the colubrids, became particularly diverse due to their preying on rodents, a mammal group that has been particularly successful. There are over 2,900 species of snakes ranging as far northward as the Arctic Circle in Scandinavia and southward through Australia and Tasmania. Snakes can be found on every continent (with the exception of Antarctica), dwelling in the sea, and as high as 16,000 feet (4,900 m)in the Himalayan Mountains of Asia. There are numerous islands from which snakes are conspicuously absent such as Ireland, Iceland, and New Zealand.