Steep environmental gradients offer important opportunities to study the interaction between natural selection and gene flow. Allele frequency clines are expected to form at loci under selection, but unlinked neutral alleles may pass easily across these clines unless a generalized barrier evolves. Here we consider the distribution of forms of the intertidal gastropod Littorina saxatilis, analyzing shell shape and amplified fragment length polymorphism (AFLP) loci on two rocky shores in Britain. On the basis of previous work, the AFLP loci were divided into differentiated and undifferentiated groups. On both shores, we have shown a sharp cline in allele frequencies between the two morphs for differentiated AFLP loci. This is coincident with a habitat transition on the shore where the two habitats (cliff and boulder field) are immediately contiguous. The allele frequency clines coincide with a cline in shell morphology. In the middle of the cline, linkage disequilibrium for the differentiated loci rises in accordance with expectation. The clines are extremely narrow relative to dispersal, probably as a result of both strong selection and habitat choice. An increase in F(ST) for undifferentiated AFLPs between morphs, relative to within-morph comparisons, is consistent with there being a general barrier to gene flow across the contact zone. These features are consistent either with an episode of allopatric divergence followed by secondary contact or with primary, nonallopatric divergence. Further data will be needed to distinguish between these alternatives.