One theory on the origins of life is that Eukaryotic cells came from prokaryotic cells.
It is also thought that a prokaryotic cell consumed another prokaryote which resisted phagocytosis. This ingested prokaryote then became integrated into the cell as the mitochondria and evolved alongside the eukaryote. The same happened for chloroplasts
This has been shown through the following:
It is now known that some bacteria can form complex membrane structures.
Sequencing of ribosomal RNA (i.e., 165 rRNA in prokaryotes and 185 rRNA for Eukaryotes) show a match between chloroplasts and cyanobacteria.