About 230 million years ago--give or take a few million years--the first dinosaurs evolved from a population of archosaurs, the "ruling lizards" that shared the earth with a host of other reptiles, including therapsids and pelycosaurs. As a group, dinosaurs were defined by a set of (mostly obscure) anatomical features, but to simplify matters a bit, the main thing that distinguished them from their archosaur forebears was their erect posture (either bipedal or quadrupedal), as evidenced by the shape and arrangement of their hip and leg bones. (See also What Is the Definition of a Dinosaur?, How Did Dinosaurs Evolve?, and a gallery of early dinosaur pictures and profiles.)
As with all such evolutionary transitions, it's impossible to identify the exact moment when the first true dinosaur walked the earth and left its archosaur ancestors in the dust. For example, the two-legged archosaur Marasuchus (sometimes identified as Lagosuchus) looked remarkably like an early dinosaur, and along with Saltopus and Procompsognathus inhabited that in-between "shadow zone" between these two forms of life. Further confusing matters, the recent discovery of a new genus of archosaur, Asilisaurus, may push back the roots of the dinosaur family tree to 240 million years ago; there are also controversial dinosaur-like footprints in Europe dating to as far back as 250 million years.
It's important to bear in mind that archosaurs didn't "disappear" when they evolved into dinosaurs--they went on living side-by-side with their eventual successors for the remainder of the Triassic period, at least 20 million years. And, to make things worse, around this same time, other populations of archosaurs went on to spawn the very first pterosaurs and the very first prehistoric crocodiles--meaning that for 20 million or so years, the late Triassic South American landscape was littered with similar-looking archosaurs, pterosaurs, two-legged "crocodyliforms," and early dinosaurs.
South America: Land of the First Dinosaurs
As far as paleontologists can tell, the earliest dinosaurs lived in the region of the supercontinent Pangea corresponding to modern-day South America. Until recently, the most famous of these creatures were the relatively large (about 400 pounds) Herrerasaurus and the medium-sized (about 75 pounds) Staurikosaurus, both of which date to about 230 million years ago. Much of the buzz has now shifted to Eoraptor, discovered in 1991, a tiny (about 20 pounds) South American dinosaur whose plain-vanilla appearance would have made it a perfect template for later specialization (by some accounts, Eoraptor may have been ancestral to lumbering, four-footed sauropods rather than agile, two-legged theropods).
A recent discovery may overturn our thinking about the South American origin of the first dinosaurs. In December of 2012, paleontologists announced the discovery of Nyasasaurus, which lived in a region of Pangaea corresponding to present-day Tanzania, in Africa. Shockingly, this slim dinosaur dates to 243 million years ago, or about 10 million years before the putative first South American dinosaurs. Still, it may yet turn out that Nyasasaurus and its relatives represented a short-lived offshoot of the early dinosaur family tree, or that it was technically an archosaur rather than a dinosaur; it's now classified, somewhat unhelpfully, as a "dinosauriform."
These early dinosaurs spawned a hardy breed that quickly (at least in evolutionary terms) radiated out to other continents. The first dinosaurs quickly made their way into the region of Pangea corresponding to North America (the prime example is Coelophysis, thousands of fossils of which have been discovered at Ghost Ranch in New Mexico, and a recent discovery, Tawa, has been adduced as further evidence for the South American origin of dinosaurs). Small to medium-sized carnivores like Podokesaurus soon made their way to eastern North America, then onward to Africa and Eurasia (a latter example being the western European Liliensternus).
The Specialization of the First Dinosaurs
The first dinosaurs existed on pretty much an equal footing with their archosaur, crocodile and pterosaur cousins; if you traveled back to the late Triassic period, you would never have guessed that these reptiles, above and beyond all the others, were fated to inherit the earth. That all changed with the still-mysterious (and little-known) Triassic-Jurassic Extinction Event, which wiped out the majority of archosaurs and therapsids ("mammal-like reptiles") but spared the dinosaurs. No one knows exactly why; it may have had something to do with the upright posture of the first dinosaurs or perhaps their slightly more sophisticated lungs.
By the start of the Jurassic period, dinosaurs had already started to diversify into the ecological niches left abandoned by their doomed cousins--the most important such event being the late Triassic split between saurischian ("lizard-hipped") and ornithischian ("bird-hipped) dinosaurs. Most of the very first dinosaurs can be considered saurischians, as can the "sauropodomorphs" into which some of these early dinosaurs evolved--slender, two-legged herbivores and omnivores that eventually evolved into the giant prosauropods of the early Jurassic period and the even bigger sauropods and titanosaurs of the later Mesozoic Era.
As far as we can tell, ornithischian dinosaurs--which included ornithopods, hadrosaurs, ankylosaurs, and ceratopsians, among other families--could trace their ancestry all the way back to Eocursor, a small, two-legged dinosaur of late Triassic South Africa. Eocursor itself would have ultimately derived from an equally small South American dinosaur, most likely Eoraptor, that lived 20 million or so years earlier--an object lesson in how such a vast diversity of dinosaurs could have originated from such a humble progenitor.