Why do some predator species specialize on only a single type of prey whereas others take a broad range? One critical determinant may be the ontogenetic range of body sizes of the predator compared to that of its prey. If any single prey taxon spans only part of the range of prey sizes ingestible by the predator, then the predator will be more likely to take multiple prey taxa. We exploit a model system that provides a robust opportunity to test this hypothesis. We studied two sympatric species of predatory sea snakes, similar in size and general ecology that feed on anguilliform fishes from different habitats in the Great Lagoon of New Caledonia. Eel species from soft-bottom habitats must construct their own burrows, and thus tend to be more slender-bodied and less variable in body size than eel species that inhabit variable-sized crevices among hard coral. As a result, a laticaudine sea snake species (Laticauda saintgironsi) that feeds on hard-coral-dwelling eels relies primarily on a single prey species: juveniles take young eels whereas adults consume adult eels of the same species. In contrast, a laticaudine species (L. laticaudata) that forages on soft-bottom eels switches its prey ontogenetically: juveniles take small eel species whereas adults consume large eel species. Thus, habitat-imposed constraints on the range of body sizes within each prey taxon generate a striking difference in the degree of dietary specialization of two closely related, sympatric predator species.