Endosymbiosis.
An ancient prokaryote developed an endomembrane system by infolding of
its plasma membrane.
Infolding also allowed it to engulf smaller cells by endocytosis.
The smaller cell may escape digestion and develop a symbiotic
relationship:
An aerobic endosymbiont may evolve into a mitochondrion and allow
its anaerobic host to use oxygen as an energy source.
Another endosymbiotic event may allow a photosynthetic prokaryotes
to become a plastid (a pigment-bearing organelle such as a
chloroplast ).