Transcriptome and genome data from twenty stony coral species and a selection of reference bilaterians were studied to elucidate coral evolutionary history. We identified genes that encode the proteins responsible for the precipitation and aggregation of the aragonite skeleton on which the organisms live, and revealed a network of environmental sensors that coordinate responses of the host animals to temperature, light, and pH. Furthermore, we describe a variety of stress-related pathways, including apoptotic pathways that allow the host animals to detoxify reactive oxygen and nitrogen species that are generated by their intracellular photosynthetic symbionts, and determine the fate of corals under environmental stress. Some of these genes arose through horizontal gene transfer and comprise at least 0.2% of the animal gene inventory. Our analysis elucidates the evolutionary strategies that have allowed symbiotic corals to adapt and thrive for hundreds of millions of years.