Spatially adjacent habitats on coral reefs can represent highly distinct environments, often harbouring different coral communities. Yet, certain coral species thrive across divergent environments. It is unknown whether the forces of selection are sufficiently strong to overcome the counteracting effects of the typically high gene flow over short distances, and for local adaptation to occur. We screened the coral genome (using restriction site-associated sequencing) and characterized both the dinoflagellate photosymbiont- and tissue-associated prokaryote microbiomes (using metabarcoding) of a reef flat and slope population of the reef-building coral, Pocillopora damicornis, at two locations on Heron Island in the southern Great Barrier Reef. Reef flat and slope populations were separated by <100 m horizontally and ~5 m vertically, and the two study locations were separated by ~1 km. For the coral host, genetic divergence between habitats was much greater than between locations, suggesting limited gene flow between the flat and slope populations. Consistent with environmental selection, outlier loci primarily belonged to the conserved, minimal cellular stress response, likely reflecting adaptation to the different temperature and irradiance regimes on the reef flat and slope. The prokaryote community differed across both habitat and, to a lesser extent, location, whereas the dinoflagellate photosymbionts differed by habitat but not location. The observed intraspecific diversity associated with divergent habitats supports that environmental adaptation involves multiple members of the coral holobiont. Adaptive alleles or microbial associations present in coral populations from the environmentally variable reef flat may provide a source of adaptive variation for assisted evolution approaches, through assisted gene flow, artificial cross-breeding or probiotic inoculations, with the aim to increase climate resilience in the slope populations.