# Evolution of reptiles

Reptiles arose about 320 million years ago during the Carboniferous period. Reptiles, in the traditional sense of the term, are defined as animals that have scales or scutes, lay land-based hard-shelled eggs, and possess ectothermic metabolisms. So defined, the group is paraphyletic, excluding endothermic animals like birds that are descended from early traditionally-defined reptiles. A definition in accordance with phylogenetic nomenclature, which rejects paraphyletic groups, includes birds while excluding mammals and their synapsid ancestors. So defined, Reptilia is identical to Sauropsida.
Though few reptiles today are apex predators, many examples of apex reptiles have existed in the past. Reptiles have an extremely diverse evolutionary history that has led to biological successes, such as dinosaurs, pterosaurs, plesiosaurs, mosasaurs, and ichthyosaurs.

## First reptiles
### Early reptiles

The origin of the reptiles lies about 320–310 million years ago, in the swamps of the late Carboniferous period, when the first reptiles evolved from advanced labyrinthodonts. The oldest known animal that may have been an amniote, a reptile rather than an amphibian, is Casineria (though it has also been argued to be a temnospondyl amphibian).
A series of footprints from the fossil strata of Nova Scotia, dated to 315 million years, show typical reptilian toes and imprints of scales. The tracks are attributed to Hylonomus, the oldest unquestionable reptile known. It was a small, lizard-like animal, about 20 to 30 cm (8–12 in) long, with numerous sharp teeth indicating an insectivorous diet.
Other examples include Westlothiana (sometimes considered a stem-amniote rather than a true amniote) and Paleothyris, both of similar build and presumably similar habit. One of the best known early reptiles is Mesosaurus, a genus from the Early Permian that had returned to water, feeding on fish.
The earliest reptiles were largely overshadowed by bigger labyrinthodont amphibians, such as Cochleosaurus, and remained a small, inconspicuous part of the fauna until after the small ice age at the end of the Carboniferous.

### Anapsids, synapsids, diapsids and sauropsids

It was traditionally assumed that first reptiles were anapsids, having a solid skull with holes only for the nose, eyes, spinal cord, etc.; the discoveries of synapsid-like openings in the skull roof of the skulls of several members of Parareptilia, including lanthanosuchoids, millerettids, bolosaurids, some nycteroleterids, some procolophonoids and at least some mesosaurs made it more ambiguous and it is currently uncertain whether the ancestral reptile had an anapsid-like or synapsid-like skull. Very soon after the first reptiles appeared, they split into two branches. One branch, Synapsida (including modern mammals), had one opening in the skull roof behind each eye. The other branch, Sauropsida, is itself divided into two main groups. One of them, the aforementioned Parareptilia, contained taxa with anapsid-like skull, as well as taxa with one opening behind each eye (see above). Members of the other group, Diapsida, possessed a hole in their skulls behind each eye, along with a second hole located higher on the skull. The function of the holes in both synapsids and diapsids was to lighten the skull and give room for the jaw muscles to move, allowing for a more powerful bite.
Turtles have been traditionally believed to be surviving anapsids, on the basis of their skull structure. The rationale for this classification was disputed, with some arguing that turtles are diapsids that reverted to this primitive state in order to improve their armor (see Parareptilia). Later morphological phylogenetic studies with this in mind placed turtles firmly within Diapsida. All molecular studies have strongly upheld the placement of turtles within diapsids, most commonly as a sister group to extant archosaurs.

### Mammalian evolution

| Tetrapods Amphibians Amniotes Sauropsids Synapsids Caseasaurs Eupelycosaurs Sphenacodontids Therapsids Mammals | Pelycosaurs |
A basic cladogram of the origin of mammals. Important developments in the transition from reptile to mammal were the evolution of warm-bloodedness, of molar occlusion, of the three-ossicle middle ear, of hair, and of mammary glands. By the end of the Triassic, there were many species that looked like modern mammals and, by the Middle Jurassic, the lineages leading to the three extant mammal groups — the monotremes, the marsupials, and the placentals — had diverged.

## Rise of dinosaurs
### Permian reptiles

Near the end of the Carboniferous, while the terrestrial reptiliomorph labyrinthodonts were still present, the synapsids evolved the first fully terrestrial large vertebrates, the pelycosaurs such as Edaphosaurus. In the mid-Permian period, the climate turned drier, resulting in a change of fauna: The primitive pelycosaurs were replaced by the more advanced therapsids.
The anapsid reptiles, whose massive skull roofs had no postorbital holes, continued and flourished throughout the Permian. The pareiasaurs reached giant proportions in the late Permian, eventually disappearing at the close of the period.
Late in the period, the diapsid reptiles split into two main lineages, the archosaurs (ancestors of crocodiles and dinosaurs) and the lepidosaurs (predecessors of modern tuataras, lizards, and snakes). Both groups remained lizard-like and relatively small and inconspicuous during the Permian.

### The Mesozoic era, the "Age of Reptiles"

The close of the Permian saw the greatest mass extinction known (see the Permian–Triassic extinction event). Most of the earlier anapsid/synapsid megafauna disappeared, being replaced by the archosauromorph diapsids. The archosaurs were characterized by elongated hind legs and an erect pose, the early forms looking somewhat like long-legged crocodiles. The archosaurs became the dominant group during the Triassic period, developing into the well-known dinosaurs and pterosaurs, as well as the pseudosuchians. The Mesozoic is often called the "Age of Reptiles", a phrase coined by the early 19th-century paleontologist Gideon Mantell who recognized the dinosaurs and the ancestors of the crocodilians as the dominant land vertebrates. Some of the dinosaurs were the largest land animals ever to have lived while some of the smaller theropods gave rise to the first birds.
The sister group to Archosauromorpha is Lepidosauromorpha, containing squamates and rhynchocephalians, as well as their fossil relatives. Lepidosauromorpha contained at least one major group of the Mesozoic sea reptiles: the mosasaurs, which emerged during the Cretaceous period. The phylogenetic placement of other main groups of fossil sea reptiles – the sauropterygians and the ichthyosaurs, which evolved in the early Triassic and in the Middle Triassic respectively – is more controversial. Different authors linked these groups either to lepidosauromorphs or to archosauromorphs, and ichthyosaurs were also argued to be diapsids that did not belong to the least inclusive clade containing lepidosauromorphs and archosauromorphs.
The therapsids came under increasing pressure from the dinosaurs in the Jurassic; the mammals and the tritylodontids were the only survivors of the line by the end of the period.

### Bird evolution

The main points to the transition from reptile to bird are the evolution from scales to feathers, the evolution of the beak (although independently evolved in other organisms), the hollowfication of bones, development of flight, and warm-bloodedness.
The evolution of birds is thought to have begun in the Jurassic Period, with the earliest birds derived from theropod dinosaurs. Birds are categorized as a biological class, Aves. The earliest known species in Aves is Archaeopteryx lithographica, from the Late Jurassic period. Modern phylogenetics place birds in the dinosaur clade Theropoda. According to the current consensus, Aves and Crocodilia are the sole living members of an unranked clade, the Archosauria.
Simplified cladogram from Senter (2007).

### Demise of the dinosaurs

The close of the Cretaceous period saw the demise of the Mesozoic era reptilian megafauna. Along with massive amount of volcanic activity at the time, the meteor impact that created the Cretaceous–Paleogene boundary is accepted as the main cause for this mass extinction event. Of the large marine reptiles, only sea turtles are left, and, of the dinosaurs, only the small feathered theropods survived in the form of birds. The end of the “Age of Reptiles” led to the “Age of Mammals”. Despite the change in phrasing, reptile diversification continued throughout the Cenozoic. Today, squamates make up the majority of extant reptiles today (over 90%). There are approximately 9,766 extant species of reptiles, compared with 5,400 species of mammals, so the number of reptilian species (without birds) is nearly twice the number of mammals.

### Role reversal

After the Cretaceous–Paleogene extinction event wiped out all of the non-avian dinosaurs (birds are generally regarded as the surviving dinosaurs) and several mammalian groups, placental and marsupial mammals diversified into many new forms and ecological niches throughout the Paleogene and Neogene eras. Some reached enormous sizes and almost as wide a variation as the dinosaurs once did. Nevertheless, mammalian megafauna never quite reached the skyscraper heights of some sauropods.
Nonetheless, large reptiles still composed important megafaunal components, such as giant tortoises, large crocodilians and, more locally, large varanids.

## The four orders of Reptilia
### Testudines

Testudines, or turtles, may have evolved from anaspids, but their exact origin is unknown and heavily debated. Fossils date back to around 220 million years ago and share remarkably similar characteristics. These first turtles retain the same body plan as do all modern testudines and are mostly herbivorous, with some feeding exclusively on small marine organisms. The trade-mark shell is believed to have evolved from extensions from their backbone and widened ribs that fused together. This is supported by the fossil of Odontochelys semitestacea, which has an incomplete shell originating from the ribs and back bone. This species also had teeth with its beak, giving more support to it being a transitional fossil, although this claim is still controversial. This shell evolved to protect against predators, but also slows down the land-based species by a great amount. This has caused many species to go extinct in recent times. Because of alien species out-competing them for food and the inability to escape from humans, there are many endangered species in this order.

### Sphenodontia

Sphenodontians arose in the mid Triassic and now consists of a single genus, tuatara, which comprises two endangered species that live on New Zealand and some of its minor surrounding islands. Their evolutionary history is filled with many species. Recent paleogenetic discoveries show that tuataras are prone to quick speciation.

### Squamata

The most recent order of reptiles, squamates, are recognized by having a movable quadrate bone (giving them upper-jaw movement), possessing horny scales and hemipenes. They originate from the early Jurassic and are made up of the three suborders Lacertilia (paraphyletic), Serpentes, and Amphisbaenia. Although they are the most recent order, squamates contain more species than any of the other reptilian orders. Squamates are a monophyletic group included, with the Sphenodontia (e.g. tuataras), in the Lepidosauria. The latter superorder, together with some extinct animals like the plesiosaurs, constitute the Lepidosauromorpha, the sister infraclass to the group, the Archosauromorpha, that contains crocodiles, turtles, and birds. Although squamate fossils first appear in the early Jurassic, mitochondrial phylogenetics suggests that they evolved in the late Permian. Most evolutionary relationships within the squamates are not yet completely worked out, with the relationship of snakes to other groups being most problematic. From morphological data, Iguanid lizards have been thought to have diverged from other squamates very early, but recent molecular phylogenies, both from mitochondrial and nuclear DNA, do not support this early divergence. Because snakes have a faster molecular clock than other squamates, and there are few early snake and snake ancestor fossils, it is difficult to resolve the relationship between snakes and other squamate groups.

### Crocodilia

The first organisms that showed similar characteristics of Crocodilians were the Crurotarsi, who appeared during the early Triassic 250 million years ago. This quickly gave rise to the Eusuchia clade 220 million years ago, which would eventually lead to the order of Crocodilians, the first of which arose about 85 million years ago during the late Cretaceous. The earliest fossil evidence of eusuchians is of the genus Isisfordia. Early species mainly fed on fish and vegetation. They were land-based, most having long legs (when compared to modern crocodiles) and many were bipedal. As diversification increased, many apex predators arose, all of which are now extinct. Modern Crocodilia arose through specific evolutionary traits. The complete loss of bipedalism was traded for a generally low quadrupedal stance for an easy and less noticeable entrance to bodies of water. The shape of the skull/jaw changed to allow more grasp along with upward-pointing nostrils and eyes. Mimicry is evident, as the backs of all crocodilia resemble some type of floating log and their general color scheme of brown and green mimics moss or wood. Their tail also took on a paddle shape to increase swimming speed. The only remaining groups of this order are the alligators, caimans, crocodiles, gharials, and false gharials.