Cyanobacteria in the genus Acaryochloris are the only known oxyphototrophs that have exchanged chlorophyll a (Chl a) with Chl d as their primary photopigment, facilitating oxygenic photosynthesis with near infrared (NIR) light. Yet their ecology and natural habitats are largely unknown. We used hyperspectral and variable chlorophyll fluorescence imaging, scanning electron microscopy, photopigment analysis and DNA sequencing to show that Acaryochloris-like cyanobacteria thrive underneath crustose coralline algae in a widespread endolithic habitat on coral reefs. This finding suggests an important role of Chl d-containing cyanobacteria in a range of hitherto unexplored endolithic habitats, where NIR light-driven oxygenic photosynthesis may be significant.