Today's crocodilians are often said to be survivors from the age of dinosaurs. That's true as far as it goes: Modern crocs have been around for some 80 million years. But they're only a small sampling of the crocodilian relatives that once roamed the planet—and, in fact, once ruled it.
Crurotarsans (a term paleontologists use to include all croc relatives) appeared about 240 million years ago, generally at the same time as dinosaurs. During the Triassic period, crocodile ancestors radiated into a wide array of terrestrial forms, from slender, long-legged animals something like wolves to huge, fearsome predators at the top of the food chain. Some, like the animal called Effigia, walked at least part of the time on two legs and were probably herbivores. So dominant were crurotarsans on land that dinosaurs were limited in the ecological niches they could occupy, staying mostly small in size and uncommon in number.
At the end of the Triassic, about 200 million years ago, an unknown cataclysm wiped out most crurotarsans. With the land cleared of their competitors, dinosaurs took over. At the same time, huge swimming predators such as plesiosaurs had evolved in the ocean, leaving little room for interlopers. The crocs that survived took on a new diversity of forms, but eventually they lived, as their descendants do today, in the only places they could: rivers, swamps, and marshes.
Restricted ecological niches may have limited the creatures' evolutionary opportunities—but also may have saved them. Many croc species survived the massive K-T (Cretaceous-Tertiary) extinction 65 million years ago, when an asteroid dealt a death blow to the dinosaurs (except for birds, now viewed as latter-day dinosaurs) and a broad range of other life on land and in the oceans. No one knows why crocs lived when so much died, but their freshwater habitat is one explanation: Freshwater species generally did better during the K-T event than did marine animals, which lost extensive shallow habitat as sea level dropped. Their wide-ranging diet and cold-blooded ability to go long periods without food may have helped as well.
With land-based dinosaurs and sea monsters gone, why didn't crocs take over the Earth once and for all? By then mammals had begun their evolutionary march toward world domination. Over time the most divergent lines of crocs died out, leaving the squat-bodied, short-legged forms we're familiar with.