Enigmatic dinosaur precursors bridge the gap to the origin of Pterosauria.
Pterosaurs were the first vertebrates to evolve powered flight<sup>1</sup> and comprised one of the main evolutionary radiations in terrestrial ecosystems of the Mesozoic era (approximately 252-66 million years ago), but their origin has remained an unresolved enigma in palaeontology since the nineteenth century<sup>2-4</sup>. These flying reptiles have been hypothesized to be the close relatives of a wide variety of reptilian clades, including dinosaur relatives<sup>2-8</sup>, and there is still a major morphological gap between those forms and the oldest, unambiguous pterosaurs from the Upper Triassic series. Here, using recent discoveries of well-preserved cranial remains, microcomputed tomography scans of fragile skull bones (jaws, skull roofs and braincases) and reliably associated postcrania, we demonstrate that lagerpetids-a group of cursorial, non-volant dinosaur precursors-are the sister group of pterosaurs, sharing numerous synapomorphies across the entire skeleton. This finding substantially shortens the temporal and morphological gap between the oldest pterosaurs and their closest relatives and simultaneously strengthens the evidence that pterosaurs belong to the avian line of archosaurs. Neuroanatomical features related to the enhanced sensory abilities of pterosaurs<sup>9</sup> are already present in lagerpetids, which indicates that these features evolved before flight. Our evidence illuminates the first steps of the assembly of the pterosaur body plan, whose conquest of aerial space represents a remarkable morphofunctional innovation in vertebrate evolution.