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: