Ecological specialization is an important engine of evolutionary change and adaptive radiation, but empirical evidence of local adaptation in marine environments is rare, a pattern that has been attributed to the high dispersal ability of marine taxa and limited geographic barriers to gene flow. The broad-nosed pipefish, Syngnathus typhle, is one of the most broadly distributed syngnathid species and shows pronounced variation in cranial morphology across its range, a factor that may contribute to its success in colonizing new environments. We quantified variation in cranial morphology across the species range using geometric morphometrics, and tested for evidence of trophic specialization by comparing individual-level dietary composition with the community of prey available at each site. Although the diets of juvenile pipefish from each site were qualitatively similar, ontogenetic shifts in dietary composition resulted in adult populations with distinctive diets consistent with their divergent cranial morphology. Morphological differences found in nature are maintained under common garden conditions, indicating that trophic specialization in S. typhle is a heritable trait subject to selection. Our data highlight the potential for ecological specialization in response to spatially variable selection pressures in broadly distributed marine species.