Main

Pterosaurs are deeply rooted in popular culture, are frequently portrayed in books and films10, and include the largest flying animals ever known11. Their evolutionary history spans more than 150 million years, ending at the close of the Mesozoic era10,11. The oldest pterosaurs are from the Upper Triassic series (219–201.3 million years ago) of Europe and North America12,13, and the clade diversified into multiple ecomorphologically disparate groups by the Middle–Late Jurassic epochs11,14. The oldest recognized pterosaurs already had a highly specialized body plan linked to their ability to fly12,15, which was conserved in all pterosaurs: shoulder girdle with strongly posteroventrally enlarged coracoid braced with the sternum and laterally facing glenoid fossa; forelimb with pteroid bone and hypertrophied fourth digit supporting a membranous wing; and pelvic girdle with prepubic bone and strongly developed preacetabular process1. This highly modified anatomy results in a large morphological gap between pterosaurs and all other known Mesozoic reptiles. To complicate matters, early pterosaur specimens are small, scarce and generally represented by taphonomically compressed, almost bidimensional partial skeletons12. These preservational problems and the absence of fossils with transitional morphologies have made the origin of pterosaurs one of the most elusive questions in vertebrate evolution for more than 200 years.

Quantitative phylogenetic analyses have generally agreed that pterosaurs fall within the lineage of Archosauria (that is, the least inclusive clade that contains birds and crocodylians) leading to dinosaurs (that is, Pan-Aves = Avemetatarsalia)2,3,5,6,7,8. However, some studies have alternatively recovered pterosaurs as the sister group to all other pan-archosaurs16, among tanystropheid archosauromorphs17, among non-archosaurian archosauriforms18 or sister to the probable stem-diapsid drepanosauromorphs19. New fossil discoveries over the past few years have greatly increased the understanding of the early evolution of Pan-Aves and of the assembly of the dinosaur body plan8,20,21. Nevertheless, a clear morphological gap still remains between pterosaurs and other pan-avians. Here, using new and existing specimens of the enigmatic pan-avian clade Lagerpetidae21, we report on a previously undocumented combination of features that reduces the morphological gap between pterosaurs and other reptiles, clarifying the phylogenetic placement of Pterosauria within Pan-Aves. We present anatomical information from across the entire skeleton that demonstrates that lagerpetids are the closest-known evolutionary relatives of pterosaurs. This information derives from detailed first-hand observation of lagerpetid specimens, enhanced by three-dimensional reconstructions from microcomputed tomography scans.

Lagerpetids are small to medium-sized (usually less than 1 m long), gracile and cursorial reptiles from Middle–Upper Triassic rocks of South and North America and Madagascar21,22. Previous knowledge of lagerpetid anatomy was mostly limited to vertebrae, hindlimbs and a few cranial bones. Our data are based on improved observations across the entire skeleton of several lagerpetid taxa (Lagerpeton, Ixalerpeton, Kongonaphon and Dromomeron spp.) (Fig. 1), which elucidate their relationship to pterosaurs (Fig. 2). A newly identified partial maxilla from the holotype of Ixalerpeton and the maxilla of Kongonaphon22 have tooth crowns with convex and unserrated mesial and distal margins (Figs. 1a, 2c). The long anterior portion of the maxilla of the latter lagerpetid substantially contributes to the external naris, as in early pterosaurs12,23 (Fig. 2c, d and Extended Data Fig. 1). The dentaries of both Lagerpeton and Ixalerpeton have an edentulous anterior end that tapers to a point (Figs. 1g, 2e), resembling the condition in the early pterosaurs Seazzadactylus, Carniadactylus and Raeticodactylus12,23,24 (Fig. 2f), and most silesaurids20. The anterior region of the lagerpetid dentary is ventrally curved (Fig. 1g), similar to those of the early pterosaurs Austriadactylus and Peteinosaurus12,23,24. The lower jaw of Lagerpeton preserves articulated dentaries and lack splenials (Extended Data Fig. 2); the latter bone is fused to the dentary or restricted to the mid-point of the medial surface of the mandible in pterosaurs13. Lagerpeton and Ixalerpeton have 26–27 dentary tooth positions, sharing the high tooth count (more than 20 teeth) of several early pterosaurs13,23,24 (Figs. 1g, 2e, f and Extended Data Figs. 1, 2). The dentary tooth crowns of these lagerpetids have convex mesial and distal margins, and middle–distal crowns possess a large and tall central cusp flanked by mesiodistally aligned, small accessory cusps (Fig. 2g and Extended Data Fig. 2). Multicusped tooth crowns are rare among archosauriforms, but also occur in several early pterosaurs (for example, Austriadraco, Seazzadactylus, Raeticodactylus, Carniadactylus and Eudimorphodon)12,23,24 (Fig. 2f, h). Both lagerpetids and pterosaurs lack interdental plates (Extended Data Fig. 2), which is in contrast to most other Triassic archosauriforms6.

Fig. 1: Newly discovered and selected bones characterizing the lagerpetid body plan.
figure 1

a, b, Partial right maxilla. c, Skull roof. d, Skull roof and braincase. e, Cranial endocast. f, Right scapula. g, Left dentary. h, Left humerus. i, Partial ulna and radius. j, metacarpals I–IV and phalanx 1 of digit I. k, Ungual of manual digit IV. l, Right ilium. m, Right ischium. n, Left pubis. o, Femur. p, Pes. Images show lateral (a, f, g, km), ventral (b, c), right lateral (d, e), medial (h, i, n, p), dorsal (j) and posteromedial (o) views. af, ln, Ixalerpeton (ULBRA-PVT059). g, o, p, Lagerpeton (PVL 4625 (g) and PVL 4619 (o, p)). hk, Dromomeron romeri (GR 238). Arrows indicate the anterior direction. Scale bars, 2 mm (a, b, e), 3 mm (c, d, f, g, kn) and 5 mm (hj, o, p). Skeletal reconstruction by S. Hartman in collaboration with the authors, based on Lagerpeton, Ixalerpeton and D. romeri.

Fig. 2: Key comparisons between pterosaur and lagerpetid cranial endocasts and skeletal elements.
figure 2

a, b, Cranial endocasts. c, Partial right maxilla. d, Left maxilla (reversed). e, Left dentary. f, Right dentary. g, h, Dentary tooth crowns. i, k, Left humeri. j, Partial manus. m, Metacarpals I–III. n, o, Femora (n, left, reversed; o, right). p, q, s, Right distal portion of tibia, fibula and astragalocalcaneum. r, Right astragalocalcaneum. Images show right lateral (a, b), lateral (c, d, f), medial (e, i, k), labial (g, h), dorsal (j), dorsal or ventral (m), anterolateral (n, o, s), anterior (p, q) and posterior (r) views. a, Lagerpetid D. gregorii (TMM 31100-1334). b, Pterosaur Allkaruen (MPEF-PV 3613). c, Lagerpetid Kongonaphon (UA 10618). d, k, m, o, Pterosaur Raeticodactylus (BNM 14524). e, g, Lagerpetid Ixalerpeton (ULBRA-PVT059). h, q, Pterosaur Austriadraco (SNSB-BSPG 1994 I 51). f, Pterosaur Seazzadactylus (MFSN 21545). i, j, n, r, Lagerpetid D. romeri (GR 238 (i, j), GR 218 (n) and GR 223 (r)). p, Lagerpetid Lagerpeton (PULR 06). s, Pterosaur Peteinosaurus (MCSNB 3496). Arrows indicate the anterior direction. Scale bars, 3 mm (a, b, f, q), 2 mm (c, e, s), 5 mm (d, kp, r), 0.3 mm (g, h) and 1 cm (i, j).

The main axis of the braincase floor of Dromomeron gregorii and Ixalerpeton is anteroventrally to posterodorsally oriented, with the basipterygoid processes positioned ventrally to the basal tubera (Fig. 1d and Extended Data Fig. 3a), as also occurs in pterosaurs and several other archosauromorphs6,7. The cranial endocasts of D. gregorii and Ixalerpeton show strongly developed and posterolaterally tapering cerebellar floccular lobes, which resemble the even more developed floccular lobes of pterosaurs9,25 (Figs. 1e, 2a, b). The olfactory tract of Ixalerpeton is long and ends in broad olfactory bulbs (Fig. 1c), retaining the ancestral condition of Archosauromorpha7, whereas these structures are strongly reduced in pterosaurs9,25. In the inner ear, the portion of the semicircular canals of the endosseous labyrinth of D. gregorii, Ixalerpeton, pterosaurs and some early eusaurischian dinosaurs are taller than anteroposteriorly long, with an anterior semicircular canal that forms a considerably longer arc than the posterior semicircular canal (Fig. 2a, b, Supplementary Information).

The forelimbs of Dromomeron romeri and pterosaurs share a forearm that is longer than the humerus, including a proportionally elongated metacarpus (metacarpal III–humerus length ratio > 0.35) (Fig. 2i–m). The manual digits of D. romeri are longer than their respective metacarpal and at least one digit has a trenchant claw (Fig. 1k), as is the case in pterosaurs and some early dinosaurs (for example, Herrerasaurus and Tawa)6. By contrast, lagerpetids, as with other archosauromorphs, lack the enlargement of both the deltopectoral crest of the humerus and the fourth manual digit that characterizes pterosaur wings1. The pelvic girdles of Lagerpeton and Ixalerpeton have a long pubo-ischiadic contact that extends ventrally up to the level of the anterovental margin of the pubis, as is the case in several early pterosaurs (for example, Austriadraco, Peteinosaurus and Dimorphodon)12,23 (Fig. 1l–n and Extended Data Fig. 3b, c), but not in most other archosaurs6,7.

The femora of lagerpetids and early pterosaurs (for example, Raeticodactylus, Peteinosaurus and Dimorphodon) share a hook-shaped proximal head (Figs. 1o, 2n, o and Extended Data Fig. 3c, d). A co-ossified astragalus and calcaneum is present in both lagerpetids and pterosaurs (Fig. 2p–s), but also in heterodontosaurid ornithischians and early neotheropods6,7. The absence of both a posterior groove on the astragalus and a calcaneal tuber is shared by pterosaurs and lagerpetids (Fig. 2r, s) and independently arose in some silesaurids and early dinosaurs6.

The new anatomical information available for lagerpetids was scored in an expanded version of a comprehensive phylogenetic data matrix focused on Permo-Triassic pan-archosaurs7. Our data matrix comprises 157 species (or diagnostic specimens) scored across 822 characters, including all currently valid lagerpetid species, 9 Triassic and 4 Jurassic pterosaurs, 13 early dinosauriforms, and most non-archosaurian archosauromorphs, including 8 tanystropheids. Thus, our extensive dataset encompasses all previously hypothesized phylogenetic positions of Pterosauria based on quantitative phylogenetic analyses2,3,4,5,6,7,8,16,17,18, except a sister group relationship to drepanosauromorphs19.

Our phylogenetic analyses robustly support Lagerpetidae as the sister taxon to Pterosauria within Pan-Aves using both equally weighted maximum parsimony (Fig. 3 and Extended Data Figs. 4, 5) and Bayesian inference with a relaxed Markov k-state variable morphological clock model that incorporates taxon ages using a fossilized birth–death process (posterior probability = 0.99 for the lagerpetid–pterosaur clade) (Extended Data Fig. 6). A minimum of 33 synapomorphies distributed across the skeleton provide strong support for the Lagerpetidae and Pterosauria clade (= Pterosauromorpha). Some of these synapomorphies are unique to pterosauromorphs among early archosaurs, including a subtriangular and dorsoventrally tall floccular fossa of the braincase, a height–anteroposterior length ratio of the semicircular canals of the inner ear >0.90, a reduced to absent splenial, strongly ventrally extended pubo-ischiadic plate, and hook-shaped femoral head (a complete list of synapomorphies can be found in the Supplementary Information). Bayesian inference analyses indicate high rates of morphological change during deep pan-avian divergences, including on the branches leading to Pterosauromorpha and Lagerpetidae. These high rates contrast with the more typical ‘background’ rates found on the branch leading to Pterosauria and its internal branches (Fig. 3). By contrast, higher evolutionary rates occur on the pterosaur branch if we force the more traditional position of lagerpetids closer to dinosaurs (Extended Data Fig. 7). These results strengthen the idea that lagerpetids bridge the morphological gap to the origin of Pterosauria and suggest that the acquisition of the highly specialized pterosaur body plan did not involve faster evolutionary rates.

Fig. 3: Time-calibrated reduced strict consensus tree (after a posteriori pruning of Kongonaphon) focused on Pterosauria and Lagerpetidae.
figure 3

Red dotted structures are ancestral optimizations of the labyrinth of the inner ear (blue lines are apomorphic displacements). Violet bars indicate node temporal calibration after Bayesian analysis. White-fill circles indicate node-based clades, half-circles stem-based clades and the star an apomorphy-based clade. Labyrinths of the inner ear are in lateral view and belong to (1) Arizonasaurus, (2) D. gregorii and (3) Allkaruen. Further information is provided in the Supplementary Information.  Ch, Changhsingian; I, Induan; He, Hettangian.

Topologically constrained searches using parsimony show that the pterosaur–lagerpetid clade is robust regardless of recent instability in early pterosaur phylogenetic reconstructions12,24,25 (Supplementary Information). Branch supports of Pterosaurosauromorpha are much higher than in other pan-archosaur clades (Extended Data Figs. 4, 5), and 23 additional steps are needed to force the more traditional position of lagerpetids as the sister taxon to Dinosauriformes. We also tested previous alternative hypotheses for pterosaur relationships, finding that 44 extra steps are required to place them as non-archosaurian archosauriforms and 64 steps to force their placement as sister taxon to Tanystropheidae (but the Pterosauria and Tanystropheidae clade is sister to Lagerpetidae within Pan-Aves). These results agree with a poorly supported placement of Pterosauria outside Archosauria6,7. The possible pterosaur-relative2,3, but highly problematic taxon Scleromochlus (Upper Triassic of Scotland), was included in a secondary phylogenetic analysis (Methods) and was recovered as the sister taxon to the Pterosauria and Lagerpetidae clade within Pan-Aves (Extended Data Fig. 4).

Additional cladistic analyses included the geometric morphometric configuration of the labyrinth of the inner ear as a continuous three-dimensional character in an attempt to avoid subjective discrete character states on such a complex structure26 (Supplementary Information). The analyses suggest that the inner ear has a strong phylogenetic signal that supports a pterosaur–lagerpetid affinity (Fig. 3 and Extended Data Figs. 810).

Our improved knowledge of lagerpetid anatomy illuminates the morphology of the most immediate common ancestor before the evolution of the well-recognized pterosaur body plan. Both lagerpetids and pterosaurs share a unique inner ear morphology among archosaurs, characterized by taller than anteroposteriorly long semicircular canals (ratio > 0.9) (Fig. 3 and Extended Data Fig. 9). This is also supported by a principal component analysis that identifies proportionally tall and highly rounded semicircular canals as a trait combination that is uniquely shared by pterosaurs and lagerpetids (Extended Data Fig. 10c). Lagerpetids and pterosaurs exhibit a strong curvature of the anterior semicircular canal (arc-length versus straight-line ratio > 1.5) that results in an increased radius, which convergently evolved in a few early saurischian dinosaurs and is present in birds. The semicircular canals detect head movements (angular acceleration) and a larger radius increases the sense of equilibrium in primates and birds, and therefore is inferred to be related to arboreal, aerial or other agile forms of terrestrial locomotion and rapid movements27. Lagerpetids and pterosaurs are the only archosauriforms with a greatly enlarged floccular fossa, representing more than 40% the height of the endocranial cavity (Fig. 2a, b). A large flocculus might have been important for lagerpetid locomotion or predation, given the connection of this structure with coordination of eye, head and neck movements28. In pterosaurs, floccular enlargement has been hypothesized to be important for information processing related to flight9. Although not as developed as in pterosaurs, the relatively large lagerpetid flocculus indicates that initial enlargement of that structure occurred along the Pterosauromorpha branch. Thus, the neuroanatomy of lagerpetids has intermediate features between those of pterosaurs and other Triassic archosauriforms and may have paved the way towards the origin of active flight in pterosaurs.

The evolution of other traits associated with the acquisition of flight remains difficult to trace at the base of Pterosauromorpha with the currently available fossil record. Lagerpetid girdles and limbs lack features correlated with the flying behaviour of pterosaurs, for example, a hypertrophied deltopectoral crest of the humerus and wing digit of the manus1. However, the strongly recurved manual claws, with an inner curvature of more than 150° in D. romeri (Fig. 1k), suggests that the forelimbs had functions other than ground-dwelling locomotion, such as climbing or acquisition of prey (the inner claw curvature of ground-dwelling birds and squamates ranges from 21.5° to 125.5° and in perchers, climbers and predators ranges from 87° to 170.3°)29. Non-archosaurian archosauriforms, early crocodylian-line archosaurs and very probably aphanosaurians (the earliest pan-avians) were all quadrupedal, ground-dwelling animals30. Our observations suggest that functional forelimb versatility became widespread in ornithodirans (Fig. 3), allowing the evolution of disparate behaviours such as manual processing of food resources in dinosaurs and active flight in pterosaurs.

The recognition of lagerpetids as the sister taxon to pterosaurs provides a new framework to study the origin of Pterosauria, its specialized body plan and flying abilities. Previous phylogenetic hypotheses implied a long ghost lineage, with a minimum of 28 million years, for Pterosauria8. Our results shorten this to about 18 million years, because the oldest lagerpetids come from 237-million-year-old rocks, near the Ladinian–Carnian boundary22 (Fig. 3). Along those millions of years, the enhancement of features that were already present in the common ancestor of lagerpetids and pterosaurs allowed the latter group to explore a new adaptive landscape and conquer aerial space, which probably promted their impressive adaptive radiation.

Methods

New phylogenetic definitions

Pan-Aves Gauthier and de Queiroz, 2001 (this study), converted clade name

Registration number: 404.

Phylogenetic definition. The most inclusive clade containing Vultur gryphus Linnaeus, 1758 (Aves), but not Crocodylus niloticus Laurenti, 1768 (Crocodylia). This is a crown-based total-clade definition.

Reference phylogeny. Phylogenetic hypothesis shown in Fig. 3 and Extended Data Fig. 4. Vultur gryphus nests within Dinosauria and C. niloticus within Pseudosuchia.

Composition. The composition is based on the reference phylogeny, Pan-Aves includes Aphanosauria8 and Ornithodira (see ‘Ornithodira’).

Ornithodira Gauthier, 1986 (this study), converted clade name

Registration number: 405.

Phylogenetic definition. The least inclusive clade containing Compsognathus longipes Wagner, 1859 (Dinosauria), and Pterodactylus (originally Ornithocephalus) antiquus Sömmerring, 1812 (Pterosauria), but not Alligator (originally Crocodilus) mississippiensis Daudin, 1802 (Crocodylia). This is a minimum clade definition.

Reference phylogeny. Phylogenetic hypothesis shown in Fig. 3 and Extended Data Fig. 4. Compsognathus longipes nests within Dinosauria, P. antiquus within Pterosauria and A. mississippiensis within Pseudosuchia.

Composition. The composition is based on the reference phylogeny, Ornithodira includes the main groups Lagerpetidae (see below), Pterosauria31, Dinosauromorpha (see ‘Dinosauromorpha’) and possibly Scleromochlus taylori.

Lagerpetidae Arcucci, 1986 (this study), converted clade name

Registration number: 406.

Phylogenetic definition. The most inclusive clade containing Lagerpeton chanarensis Romer, 1971, but not Eudimorphodon ranzii Zambelli, 1973, Silesaurus opolensis Dzik, 2003, and V. gryphus Linnaeus, 1758. This is a maximum clade definition.

Reference phylogeny. Phylogenetic hypothesis shown in Fig. 3 and Extended Data Fig. 4.

Composition. The composition is based on the reference phylogeny, Lagerpetidae includes L. chanarensis, Ixalerpeton polesinensis, Kongonaphon kely and Dromomeron spp.

Dinosauromorpha Benton, 1985 (this study), converted clade name

Registration number: 407.

Phylogenetic definition. The most inclusive clade containing C. longipes Wagner, 1859 (Dinosauria), but not P. antiquus Sömmerring, 1812 (Pterosauria), or A. mississippiensis Daudin, 1802 (Crocodylia). This is a maximum clade definition.

Reference phylogeny. Phylogenetic hypothesis shown in Fig. 3 and Extended Data Fig. 4. Compsognathus longipes nests within Dinosauria, P. antiquus within Pterosauria and A. mississippiensis within Pseudosuchia.

Composition. The composition is based on the reference phylogeny, Dinosauromorpha includes the main groups Silesauridae32,33 and Dinosauria34, including Aves35, plus some species level taxa such as Lagosuchus talampayensis.

Dinosauriformes Novas, 1992 (this study), converted clade name

Registration number: 408.

Phylogenetic definition. The least inclusive clade containing C. longipes Wagner, 1859 (Dinosauria), and L. talampayensis Romer, 1971. This is a minimum clade definition.

Reference phylogeny. Phylogenetic hypothesis shown in Fig. 3 and Extended Data Fig. 4. Compsognathus longipes nests within Dinosauria.

Composition. The composition is based on the reference phylogeny, Dinosauriformes is composed of L. talampayensis, Silesauridae32,33 and Dinosauria34, including Aves35.

Microcomputed tomography scans and digital processing

The partial lower jaw of Lagerpeton (PVL 4625) was scanned using X-ray microcomputed tomography at YPF TECNOLOGÍA (Y-TEC) using a Bruker Skyscan, the bones of Ixalerpeton (ULBRA-PVT059) were scanned at Centro para Documentação da Biodiversidade, Universidade de São Paulo using a Nanotom Scan machine (GE Sensing & Inspection Technologies) and the braincase of D. gregorii (TMM 31100-1334) was scanned at the University of Texas High-Resolution X-ray CT Facility using a custom-built BIR scanner using a Feinfocus X-ray source and an Image Intensifier detector (further information about the scans is provided in the Supplementary Information). The images of Lagerpeton were processed using the software 3D Slicer version 4.736 and the images of Ixalerpeton and Dromomeron were processed using the software Amira (version 5.3.3, Visage Imaging).

Morphogeometric sampling of the endosseous labyrinth of the inner ear

The course of each semicircular canal of the inner ear was quantitatively sampled in available taxa using sliding three-dimensional semilandmarks (on left labyrinths or reflected right labyrinths). A midline skeleton of each canal was generated using the ‘autoskeleton’ function of Avizo 9 (https://www.fei.com/software/amira-avizo/), which represents the mean endolymph flow path through a semicircular canal37. The landmarking of midline skeletons captures the relative lengths, orientations and morphology of the canals. Open semilandmark curves started at the intersection of the canal with its ampulla, ending at its intersection with the common crus. These start and end points represent six fixed, single-point landmarks. The posterior ampulla was estimated to be the ventralmost point on the trajectory of the posterior semicircular canal (psc), and the intersection of the lateral semicircular canal (lsc) with the common crus was estimated to be directly ventral to the intersection of the psc with the common crus38. In addition, a closed loop of semilandmarks was placed around the inner surface of the anterior semicircular canal (asc) to capture variation in relative canal thickness39. This landmarking procedure involved placing arbitrary numbers of points in each semilandmark series. Thus, these series were resampled to equal numbers of points in each specimen using the digit.curves function of the package Geomorph (version 3.2.1)40 written for R (version 3.6.0)41: asc midline skeleton (9 points), psc midline skeleton (8 points), lsc midline skeleton (10 points) and asc inner loop (13 points). Landmark configurations were transformed through a generalized Procrustes superimposition using the gpagen function of Geomorph in R. This procedure removes differences in orientation and position of specimens and separates overall size information (centroid size) from shape information. Semilandmarks were allowed to slide along their curves during superimposition to minimize bending energy difference from the mean shape.

Principal component analysis

We conducted principal component analyses of our geometric morphometric dataset using the plotTangentSpace() function of the R package Geomorph (version 3.2.1)40.

Phylogenetic analyses

Maximum parsimony analysis

The phylogenetic relationships of pterosaurs and lagerpetids were analysed using the data matrix of a previous study7 as modified in subsequent studies (see ref. 42 and references therein). We used this data matrix because it has the key taxa and characters that are required to test the phylogenetic position of those clades within the Permo-Triassic evolutionary radiation of Pan-Archosauria. Nevertheless, we increased the sampling of the matrix by adding taxa and characters that we considered informative to assess the phylogeny of early pan-avians. We added 12 pterosaurs, 6 lagerpetids, 7 dinosaurs and 127 characters (Supplementary Information). In addition, the formulation or wording was modified or additional states were added for 76 characters, and several scorings were changed with respect to previous versions of the matrix (Supplementary Information). Character 119 was excluded before the searches following a previously published study43. Because they represent nested sets of homologies, the following characters were considered additive: 1, 2, 7, 10, 17, 19–21, 28, 29, 36, 40, 42, 46, 50, 54, 66, 71, 74–76, 122, 127, 146, 153, 156, 157, 171, 176, 177, 187, 202, 221, 227, 263, 266, 278, 279, 283, 324, 327, 331, 337, 345, 351, 352, 354, 361, 365, 370, 377, 379, 386, 387, 398, 410, 414, 424, 430, 435, 446, 448, 454, 455, 458, 460, 463, 470, 472, 478, 482, 483, 485, 489, 490, 502, 504, 510, 516, 521, 529, 537, 546, 552, 556, 557, 567, 569, 571, 574, 581, 582, 588, 636, 648, 652, 662, 701, 731, 735, 737, 738, 743, 749, 766, 784 and 816. Several terminal taxa were also excluded because they were originally scored only with the purpose of conducting morphological disparity analyses and were not intended to be included, yet, in phylogenetic analyses44. The final data matrix is composed of 822 active characters and 157 active taxa. A second analysis was conducted including S. taylori, resulting in a total of 158 taxa. Interpretation of detailed anatomical features is extremely difficult for this species, owing to the preservation of all its specimens as natural moulds of very small-sized bones in a coarse sandstone4. Thus, we decided to not include this taxon in the first analysis, because this could introduce a subtantial amount of scoring errors.

The data matrix was analysed under equally weighted maximum parsimony using TNT 1.526. The search strategies started using a combination of the tree-search algorithms Wagner trees, tree bisection and reconnection (TBR) branch swapping, sectorial searches, Ratchet and tree fusing, until 100 hits of the same minimum tree length were achieved. The best trees obtained were subjected to a final round of TBR branch swapping. Zero-length branches in any of the recovered most-parsimonious trees were collapsed. Branch support was quantified using Bremer support values and a bootstrap resampling analysis, using 1,000 technical pseudo-replicates and reporting both absolute and GC (group present/contradicted) frequencies. The minimum number of additional steps necessary to generate alternative, suboptimal topologies was calculated when constraining the position of pterosaurs and lagerpetids in different parts of the tree or constraining the topology of pterosaur interrelationships found by previous studies and rerunning the analyses.

An alternative analysis was conducted using the three-dimensional morphogeometric configuration of the endosseous labyrinth of the inner ear. The aligned (Procrustes) coordinates were exported to TNT 1.5 and they were used as a single morphogeometric continuous character26. The configurations were realigned in TNT by applying the minimum distances criterion26 and using Trilophosaurus buettneri as the reference taxon because it has been recovered as the earliest branching terminal taxon, among those with three-dimensionally sampled endosseous labyrinths, in previous analyses of this dataset7,42,43. As a secondary analysis, we used another early branching archosauromorph, Mesosuchus browni, as the reference taxon to test changes in the topologies. The discrete characters of the inner ear (characters 729–743) were excluded during the searches using the three-dimensional morphogeometric character because of their non-independence. The search strategy started using 10 technical replicates of Wagner trees followed by the TBR branch-swapping algorithm (holding 10 trees per replication). The best trees obtained were subjected to a final round of TBR branch swapping. Zero-length branches and additive characters were treated as in the previous analyses.

Bayesian inference analysis

A Bayesian tip-dating analysis was conducted in MrBayes (version 3.2.6)45. We used a Markov k-state variable substitution model and the same ordered characters as in the maximum-parsimony analysis. Petrolacosaurus kansensis was used as the outgroup. We used an independent gamma-rate relaxed-clock model and uniform age priors modelled around the first and last appearance dates for all tips of the tree. We implemented a node age calibration for Archosauria with a uniform prior of 249.2–257.3 million years ago, in which the minimum is informed by the ages of the oldest archosaurian specimens44, and the maximum by age estimates for the crocodile–lizard split46. We specified a fossilized birth–death process as the tree model using standard parameterizations and values. Fossils were specified to be tips. The deepest split within the tree was parameterized with a uniform (303.4–318.0 million years ago) tree age prior, for which the maximum is based on the age of the Joggins Formation, which documents the earliest crown-amniotes47 and the minimum is based on the chronostratigraphic uncertainty of P. kansensis, the outgroup and oldest taxon of our sample. We used metropolis-coupling Markov chain Monte Carlo algorithms with two independent runs of four chains, using a heating coefficient of 0.05 and 3 swap attempts per generation. Topological convergence, indicated by average standard deviation of split frequencies decreasing below 0.01, was achieved after 23,496,000 generations. Potential scale reduction factors of 1.0, visual inspection of trace plot with Tracer (version 1.7.1)48 and estimated sample sizes (ESS) for all parameters >200 further indicated convergence. An additional analysis was performed with the same settings, except that the topology was constrained to investigate topological effects on evolutionary rates. The topology is constrained to follow the topology of one of the most-parsimonious trees of the maximum-parsimony analysis after constraining lagerpetids to be dinosauromorphs. This analysis was specified to run for 24,000,000 generations and estimated sample sizes >200 indicated convergence. Additional phylogenetic analysis details are provided in the Supplementary Information.

Reporting summary

Further information on research design is available in the Nature Research Reporting Summary linked to this paper.