Extant crocodylomorphs are semiaquatic ambush predators largely restricted to freshwater or estuarine environments, but the group is ancestrally terrestrial and inhabited a variety of ecosystems in the past. Despite its rich ecological history, little effort has focused on elucidating the historical pattern of ecological transitions in the group. Traditional views suggested a single shift from terrestrial to aquatic in the Early Jurassic. However, new fossil discoveries and phylogenetic analyses tend to imply a multiple-shift model. Here we estimate ancestral habitats across a comprehensive phylogeny and show at least three independent shifts from terrestrial to aquatic and numerous other habitat transitions. Neosuchians first invade freshwater habitats in the Jurassic, with up to four subsequent shifts into the marine realm. Thalattosuchians first appear in marine habitats in the Early Jurassic. Freshwater semiaquatic mahajangasuchids are derived from otherwise terrestrial notosuchians. Within nearly all marine groups, some species return to freshwater environments. Only twice have crocodylomorphs reverted from aquatic to terrestrial habitats, both within the crown group. All living non-alligatorid crocodylians have a keratinised tongue with salt-excreting glands, but the lack of osteological correlates for these adaptations complicates pinpointing their evolutionary origin or loss. Based on the pattern of transitions to the marine realm, our analysis suggests at least four independent origins of saltwater tolerance in Crocodylomorpha.