Theory defines conditions under which sympatric speciation may occur, and several possible examples of the process in action have been identified. In most cases, organisms specialize onto habitats that fall into discrete categories, such as host species used by herbivores and parasites. Ecological specialization within a continuous habitat gradient is theoretically possible, but becomes less likely with increasing gene flow among clinal habitat types. Here, I show that habitat race formation is underway in a frog, Rana temporaria, along a continuous and spatially mosaic habitat gradient. Tadpoles from 23 populations raised in an outdoor mesocosm experiment showed adaptive phenotypic variation correlated with the predator density in their pond of origin. A survey of microsatellite markers in 48 populations found that neutral genetic divergence was enhanced between ponds with very different densities of predators. This represents a new example of habitat specialization along a continuous habitat gradient with no spatial autocorrelation in habitat.