Apicomplexa is a group of obligate intracellular parasites that includes the causative agents of human diseases such as malaria and toxoplasmosis. Apicomplexans evolved from free-living phototrophic ancestors, but how this transition to parasitism occurred remains unknown. One potential clue lies in coral reefs, of which environmental DNA surveys have uncovered several lineages of uncharacterized basally branching apicomplexans1,2. Reef-building corals have a well-studied symbiotic relationship with photosynthetic Symbiodiniaceae dinoflagellates (for example, Symbiodinium3), but the identification of other key microbial symbionts of corals has proven to be challenging4,5. Here we use community surveys, genomics and microscopy analyses to identify an apicomplexan lineage-which we informally name 'corallicolids'-that was found at a high prevalence (over 80% of samples, 70% of genera) across all major groups of corals. Corallicolids were the second most abundant coral-associated microeukaryotes after the Symbiodiniaceae, and are therefore core members of the coral microbiome. In situ fluorescence and electron microscopy confirmed that corallicolids live intracellularly within the tissues of the coral gastric cavity, and that they possess apicomplexan ultrastructural features. We sequenced the genome of the corallicolid plastid, which lacked all genes for photosystem proteins; this indicates that corallicolids probably contain a non-photosynthetic plastid (an apicoplast6). However, the corallicolid plastid differs from all other known apicoplasts because it retains the four ancestral genes that are involved in chlorophyll biosynthesis. Corallicolids thus share characteristics with both their parasitic and their free-living relatives, which suggests that they are evolutionary intermediates and implies the existence of a unique biochemistry during the transition from phototrophy to parasitism.