Mitochondria and chloroplasts display similarities with bacteria that led to the endosymbiont theory. This theory states that an early ancestor of eukaryotic cells engulfed an oxygen-using non-photosynthetic prokaryotic cell. Eventually, the engulfed cell formed a relationship with the host cell in which it was enclosed, becoming an endosymbiont, a cell living within another cell. Indeed, over the course of evolution, the host cell and its endosymbiont merged into a single organism, a eukaryotic cell with a mitochondrion. At least one of these cells may have then taken up a photosynthetic prokaryote, becoming the ancestor of eukaryotic cells that contain chloroplasts.
— Campbell Biology AP Edition