Endosymbiosis

Endosymbiosis occurs when a symbiont lives inside the body or the cells of another organism. It is a very widespread phenomenon in living things.
Examples are:
Rhizobia: nitrogen-fixing bacteria which live in root nodules on plants of the pea family.
Singly-celled forams which include a single-celled alga inside the cell. This is 'facultative', which means they may or may not do it. A more far-reaching version is idioplastic endosymbiosis. Here, the foram consumes the alga, but keeps its chloroplasts in working order.
Green algae inside marine polychaete worms.
Single-celled algae inside reef-building corals.
Gut flora (often flagellates) inside the digestive systems of insects and vertebrates which digest plant cellulose. These are 'obligate' symbionts, which means the host must have them.
Lichen: fungus+alga or bacterium.
Mycorrhiza: fungal hyphae and roots of trees.
Eukaryote theory
Endosymbiont theory is the idea that eukaryote cells arose in evolution by the fusion of previously free-living protists (prokaryotes).p143 The theory was first suggested by the Russian botanist Konstantin Mereshkovsky in 1905. The nature of lichens had been worked out; mitochondria and chloroplasts had been seen in cells, and their similarity to bacteria noted. The theory was initially dismissed, but was re-examined when more was known about cell biology, by Lynn Margulis
The eukaryote cell is the type of cell all animals and plants are made of. Some cell organelles, such as mitochondria and chloroplasts, contain DNA. In each case, this DNA is thought to be the remnant of the genome of a once independent bacterium. The theory is that the eukaryote cell evolved by the fusion of several bacteria or archaean organisms. Together, the new cells survived, prospered and evolved into new and complex forms of life. The origin of other organelles in the eukaryotic cell is still under review: the cell nucleus, its membrane, chromosomes and centromeres; the Golgi body; the flagella or cilia; the intracellular membranes. Some of these may also have had a symbiotic origin.
Examples:
Mitochondria live inside the cells of all animals, plants, and fungi. They make a fuel for the cells called ATP; it is the most common fuel in the body. Mitochondria were once bacteria, but now they cannot live outside animal cells.
Choroplasts are plastids which live inside the cells of photosynthetic organisms. They contain chlorophyll, which grabs energy from sunlight and makes it into sugar. Chloroplasts were once cyanobacteria. Glaucophytes are an algae with chloroplasts that are more like blue-green bacteria: the cell walls are still sensitive to antibiotics.
Kelp and other brown algae are different from other endosymbiotic associations. A brown algae cell fused with the cell of a green algae, which already had an endosymbiont. This is called secondary endosymbiosis.
The endosymbiont for some dinoflagellates was once a brown algae. This is called tertiary (third) endosymbiosis.
Endosymbiosis in prokaryotes
There is evidence that symbiosis happened between ancient bacteria to produce the double-membrane class known as gram-negative bacteria. Since the gram-negative bacteria include the cyanobacteria, this was the first of several such events in the history of the eukaryotes.
References
Evolutionary biology
Cell biology
Microbiology