Dinosaurs didn't spring suddenly into existence two hundred million years ago, huge, toothy, and hungry for grub. Like all living things, they evolved, slowly and gradually, according to the rules of Darwinian selection and adaptation, from previously existing creatures-in this case, a family of primitive reptiles known as archosaurs ("ruling lizards").
On the face of it, archosaurs weren't all that different from the dinosaurs that succeeded them. However, these Triassic reptiles were much smaller than later dinosaurs, and they possessed certain characteristic features that set them apart from their more famous descendants (most notably, the lack of a "locked-in" posture for their front and hind limbs). Paleontologists may even have identified the single genus of archosaur from which all dinosaurs evolved: Lagosuchus (Greek for "rabbit crocodile"), a quick, tiny reptile that scurried across the forests of early Triassic South America, and that sometimes goes by the name Marasuchus.
Evolution During the Triassic Period
Confusing matters somewhat, the archosaurs of the middle to late Triassic period didn't only give rise to dinosaurs. Isolated populations of these "ruling reptiles" also spawned the very first pterosaurs and crocodiles. For as much as 20 million years, in fact, the part of the Pangean supercontinent corresponding to modern-day South America was thick with two-legged archosaurs, two-legged dinosaurs, and even two-legged crocodiles-and even experienced paleontologists sometimes have trouble distinguishing between the fossil specimens of these three families!
Experts are unsure whether the archosaurs from which the dinosaurs descended coexisted with the therapsids (mammal-like reptiles) of the late Permian period, or whether they appeared on the scene after the Permian/Triassic Extinction Event 250 million years ago, a geologic upheaval that killed about three-quarters of all land-dwelling animals on earth. From the perspective of dinosaur evolution, though, this may be a distinction without a difference. What's clear is that dinosaurs gained the upper hand by the start of the Jurassic period. (By the way, you may be surprised to learn that therapsids spawned the first mammals around the same time, the late Triassic period, as archosaurs spawned the first dinosaurs.)
The First Dinosaurs
Once you climb your way out of late Triassic South America, the path of dinosaur evolution comes into much sharper focus, as the very first dinosaurs slowly radiated into the sauropods, tyrannosaurs, and raptors we all know and love today. The best current candidate for the "first true dinosaur" is the South American Eoraptor, a nimble, two-legged meat-eater akin to the slightly later Coelophysis of North America. Eoraptor and its ilk survived by eating the smaller crocodiles, archosaurs, and proto-mammals of its lush forest environment, and may have hunted by night.
The next important event in dinosaur evolution, after the appearance of Eoraptor, was the split between saurischian ("lizard-hipped") and ornithischian ("bird-hipped") dinosaurs, which transpired just before the start of the Jurassic period. The first ornithischian dinosaur (a good candidate is Pisanosaurus) was the direct descendant of the vast bulk of the plant-eating dinosaurs of the Mesozoic Era, including ceratopsians, hadrosaurs, and ornithopods. Saurischians, meanwhile, split into two main families: theropods (the meat-eating dinosaurs, including tyrannosaurs and raptors) and prosauropods (the slender, bipedal, plant-eating dinosaurs that later evolved into gigantic sauropods and titanosaurs). A good candidate for the first prosauropod, or "sauropodomorph," is Panphagia, the name of which is Greek for "eats everything."
Ongoing Dinosaur Evolution
Once these major dinosaur families were established, around the start of the Jurassic period, evolution continued to take its natural course. But according to recent research, the pace of dinosaur adaptation slowed down drastically during the later Cretaceous period, when dinosaurs were more rigidly locked into existing families and their rates of speciation and diversification slowed. The corresponding lack of diversity may have made dinosaurs ripe pickings for the K/T Extinction Event when a meteor impact decimated planetary food supplies. Ironically, just the way the Permian/Triassic Extinction Event paved the way for the rise of dinosaurs, the K/T Extinction cleared the way for the rise of mammals-which had existed alongside the dinosaurs all along, in small, quivering, mouse-like packages.