Nematodes are the only major metazoan group which is persistently abundant and diverse across marine, freshwater and terrestrial ecosystems. This could be the result of a few major habitat transitions followed by extensive diversification, or numerous habitat transitions followed by moderate diversification. To pinpoint habitat transitions, we superposed nematode habitat associations on an available phylum-wide phylogenetic tree based on small subunit ribosomal DNA sequences (≈2730 SSU rDNA sequences covering ≈1750 nematode taxa). Our analysis revealed at least 30 major habitat transitions within the phylum Nematoda. These transitions as well as their directionality were unevenly spread over the 12 major clades. Most transitions reside in Clades 1–6, and these transitions are bidirectional. Members of Clades 8–12 showed five full transitions, and these took place exclusively from terrestrial to marine systems. We relate our results to the distinct secretory–excretory systems in Clades 1–6 and Clades 8–12, as well as to differences in water permeability of the nematode cuticle. Hence, the phylum Nematoda is characterized by a relatively large number of habitat transitions followed by moderate diversification. The identification of multiple habitat transitions at a low taxonomic level will facilitate future investigations into the mechanisms underlying this unusual ecological flexibility.