Trilobites comprise a major group of extinct marine arthropods, which thrived in a variety of habitats surrounding the Palaeozoic palaeocontinents. The evidence that can be used to infer their ecology is reviewed, including functional anatomy, field occurrence and geology in comparison with living arthropods and palaeogeography. Where different lines of evidence are consistent with one interpretation, the inferred life habits are considered well supported, but there remain some intriguing enigmas. Trilobites occupied many of the ecological niches available to living marine arthropods, including the pelagic realm. Benthic species included predator/scavengers, grazers and particle feeders, and specialist filter feeders. Different contemporaneous natural assemblages of trilobites occupied different habitats ranging from shallow water to deep environments, which are characterized by distinctive suites of genera (biofacies). Such differentiation was already well established in the Cambrian. Dispersed palaeocontinents through much of the Palaeozoic further encouraged the evolution of endemics and distinct suites of taxa in relation to palaeolatitude. Taken together, these factors go some way towards explaining the great variety of species that evolved during more than 250 million years of their history.