Respiration is a major trait shaping the biology of many environments. Cytochrome oxidase containing heme A (COX) is a common terminal oxidase in aerobic bacteria and is the only one in mammalian mitochondria. The synthesis of heme A is catalyzed by heme A synthase (CtaA/Cox15), an enzyme that most likely coevolved with COX. The evolutionary origin of COX in bacteria has remained unknown. Using extensive sequence and phylogenetic analysis, we show that the ancestral type of heme A synthases is present in iron-oxidizing Proteobacteria such as Acidithiobacillus spp. These bacteria also contain a deep branching form of the major COX subunit (COX1) and an ancestral variant of CtaG, a protein that is specifically required for COX biogenesis. Our work thus suggests that the ancestors of extant iron-oxidizers were the first to evolve COX. Consistent with this conclusion, acidophilic iron-oxidizing prokaryotes lived on emerged land around the time for which there is the earliest geochemical evidence of aerobic respiration on earth. Hence, ecological niches of iron oxidation have apparently promoted the evolution of aerobic respiration.