Broadcast-spawning coral species have wide geographic ranges, spanning strong environmental gradients, but it is unclear how much spatially varying selection these gradients actually impose. Strong divergent selection might present a considerable barrier for demographic exchange between disparate reef habitats. We investigated whether the cross-shelf gradient (nearshore - offshore - deep) is associated with spatially varying selection in two common coral species, Montastraea cavernosa and Siderastrea siderea, in the Florida Keys. Toward this end, we generated a de novo genome assembly for M. cavernosa and used 2bRAD to genotype 20 juveniles and 20 adults of both species from each of the three reef zones to identify signatures of selection occurring within a single generation. Unexpectedly, each species was found to be composed of four genetically distinct lineages, with gene flow between them still ongoing but highly reduced in 13.0-54.7% of the genome. Each species includes two sympatric lineages that are only found in the deep (20 m) habitat, while the other lineages are found almost exclusively on the shallower reefs (3-10 m). The two “shallow” lineages of M. cavernosa are also specialized for either nearshore or offshore: comparison between adult and juvenile cohorts indicates that cross-shelf migrants are more than twice as likely to die before reaching adulthood than local recruits. Siderastrea siderea and M. cavernosa are among the most ecologically successful species on the degraded Florida Keys Reef Tract, and this work offers important insight on the genomic background of divergent selection and environmental specialization that may in part explain their resilience and broad environmental range.