An ancient prokaryote developed an endomembrane system that allowed it to engulf smaller cells and package them within vesicles.
The smaller cell may escape digestion and develop a symbiotic relationship: an aerobic endosymbiont may allow its anaerobic host to use the increasing oxygen in the environment, and evolve into a mitochondrion.
Another endosymbiotic event may allow a photosynthetic endosymbiont to become a plastid such as a chloroplast.