According to the most accepted hypothesis aerobic eukaryotic cells emerged from the association of aerobic prokaryotes engulfed by primitive anaerobic eukaryotic cells. This would have been the origin of mitochondria that thus would have primitively been aerobic bacteria engulfed by eukaryotic anaerobes. This hypothesis is called the endosymbiotic hypothesis on the origin of mitochondria.
Chloroplasts would also have appeared by endosymbiosis from the entry of photosynthetic prokaryotes into aerobic eukaryotes, both establishing a mutualist ecological interaction.