An anapsid is an amniote whose skull lacks one or more skull openings (fenestra, or fossae) near the temples. Traditionally, the Anapsida are the most primitive subclass of amniotes, the ancestral stock from which Synapsida and Diapsida evolved, making anapsids paraphyletic. It is however doubtful that all anapsids lack temporal fenestra as a primitive trait, and that all the groups traditionally seen as anapsids truly lacked fenestra.
While "anapsid reptiles" or "anapsida" were traditionally spoken of as if they were a monophyletic group, it has been suggested that several groups of reptiles that had anapsid skulls might be only distantly related. Scientists still debate the exact relationship between the basal (original) reptiles that first appeared in the late Carboniferous, the various Permian reptiles that had anapsid skulls, and the Testudines (turtles, tortoises, and terrapins). However, it was later suggested that the anapsid-like turtle skull is due to reversion rather than to anapsid descent. The majority of modern paleontologists believe that the Testudines are descended from diapsid reptiles that lost their temporal fenestrae. More recent morphological phylogenetic studies with this in mind placed turtles firmly within diapsids, or, more commonly, within Archelosauria.
All molecular studies have strongly upheld the placement of turtles within diapsids; some place turtles within Archosauria, or, more commonly, as a sister group to extant archosaurs. One of the most recent molecular studies, published on 23 February 2012, suggests that turtles are lepidosauromorph diapsids, most closely related to the lepidosaurs (lizards, snakes, and tuataras). However, in a later paper from the same authors, published in 2014, based on more extensive data, the archosauromorph hypothesis is supported.
Reanalysis of prior phylogenies suggests that they classified turtles as anapsids both because they assumed this classification (most of them were studying what sort of anapsid turtles are) and because they did not sample fossil and extant taxa broadly enough for constructing the cladogram. Testudines is suggested to have diverged from other diapsids between 200 and 279 million years ago, though the debate is far from settled. Although procolophonids managed to survive into the Triassic, most of the other reptiles with anapsid skulls, including the millerettids, nycteroleterids, and pareiasaurs, became extinct in the Late Permian period by the Permian-Triassic extinction event.
Despite the molecular studies, there is evidence that contradicts their classification as diapsids. All known diapsids excrete uric acid as nitrogenous waste (uricotelic), and there is no known case of a diapsid reverting to the excretion of urea (ureotelism), even when they return to semi-aquatic lifestyles. Crocodilians, for example, are still uricotelic, although they are also partly ammonotelic, meaning they excrete some of their waste as ammonia. Ureotelism appears to be the ancestral condition among primitive amniotes, and it is retained by mammals, which likely inherited ureotelism from their synapsid and therapsid ancestors. Ureotelism therefore would suggest that turtles were more likely anapsids than diapsids. The only known uricotelic chelonian is the desert tortoise, which likely evolved it recently as adaptation to desert habitats. Some desert mammals are also uricotelic, so since practically all known mammals are ureotelic, uricotelic adaptation is a likely result of convergence among desert species. Therefore, turtles would have to be the only known case of a uricotelic reptile reverting to ureotelism.
Anapsida is still sporadically recognized as a valid group, but this is not favoured by current workers. Anapsids in the traditional meaning of the word are not a clade, but rather a paraphyletic group composed of all the early reptiles retaining the primitive skull morphology, grouped together by the absence of temporal openings. Gauthier, Kluge and Rowe (1988) attempted to redefine Anapsida so it would be monophyletic, defining it as the clade containing "extant turtles and all other extinct taxa that are more closely related to them than they are to other reptiles".
This definition explicitly includes turtles in Anapsida; because the phylogenetic placement of turtles within Amniota is very uncertain, it is unclear what taxa, other than turtles themselves, would be included in such defined Anapsida, and whether its content would be similar to the Anapsida of tradition. Indeed, Gauthier, Kluge and Rowe (1988) themselves included only turtles and Captorhinidae in their Anapsida, while excluding the majority of anapsids in the traditional sense of the word from it.
Tsuji and Müller (2009) noted that the name Anapsida implies a morphology (lack of temporal openings) that is in fact absent in the skeletons of a number of taxa traditionally included in the group. A temporal opening in the skull roof behind each eye, similar to that present in the skulls of synapsids, has been discovered in the skulls of a number of members of Parareptilia (the clade containing most of reptiles traditionally referred to as anapsids), including lanthanosuchoids, millerettids, bolosaurids, some nycteroleterids, some procolophonoids and at least some mesosaurs. The presence of temporal openings in the skulls of these taxa makes it uncertain whether the ancestral reptiles had an anapsid-like skull as traditionally assumed or a synapsid-like skull instead.