Endosymbiotic theory
The endosymbiotic theory concerns the origins of mitochondria and plastids (e.g. chloroplasts), which are organelles of eukaryotic cells. According to this theory, these organelles originated as separate prokaryotic organisms which were taken inside the cell as endosymbionts. Mitochondria developed from proteobacteria (in particular, Rickettsiales or close relatives) and chloroplasts from cyanobacteria.

# History
The endosymbiotic theory was first articulated by the Russian botanist Konstantin Mereschkowski in 1905. Mereschkowsky was familiar with work by the German botanist Andreas Schimper, who had observed in 1883 that the division of chloroplasts in green plants closely resembled that of free-living cyanobacteria, and who had himself tentatively proposed (in a footnote) that green plants had arisen from a symbiotic union of two organisms.
Ivan Wallin extended the idea of an endosymbiotic origin to mitochondria in the 1920s. These theories were initially dismissed or ignored. More detailed electron microscopic comparisons between cyanobacteria and chloroplasts (for example studies by Hans Ris), combined with the discovery that plastids and mitochondria contain their own DNA (which by that stage was recognized to be the hereditary material of organisms) led to a resurrection of the idea in the 1960s.
The endosymbiotic hypothesis was fleshed out and popularized by Lynn Margulis. In her 1981 work Symbiosis in Cell Evolution she argued that eukaryotic cells originated as communities of interacting entities, including endosymbiotic spirochaetes that developed into eukaryotic flagella and cilia. This last idea has not received much acceptance, since flagella lack DNA and do not show ultrastructural similarities to prokaryotes. See also Evolution of flagella.
According to Margulis and Sagan, "Life did not take over the globe by combat, but by networking" (i.e., by cooperation), and Darwin's notion of evolution driven by natural selection is incomplete (see Evolution).
The possibility that peroxisomes may have an endosymbiotic origin has also been considered, although they lack DNA. Christian de Duve proposed that they may have been the first endosymbionts, allowing cells to withstand growing amounts of free molecular oxygen in the Earth's atmosphere. However, it now appears that they may be formed de novo, contradicting the idea that they have a symbiotic origin (Gabaldon et al. 2006).

# Evidence
Evidence that mitochondria and plastids arose from ancient endosymbiosis of bacteria is as follows:
- Both mitochondria and plastids contain DNA that is different from that of the cell nucleus and that is similar to that of bacteria (in being circular and in its size).
- They are surrounded by two or more membranes, and the innermost of these shows differences in composition from the other membranes of the cell. The composition is like that of a prokaryotic cell membrane.
- New mitochondria and plastids are formed only through a process similar to binary fission. In some algae, such as Euglena, the plastids can be destroyed by certain chemicals or prolonged absence of light without otherwise affecting the cell. In such a case, the plastids will not regenerate.
- Much of the internal structure and biochemistry of plastids, for instance the presence of thylakoids and particular chlorophylls, is very similar to that of cyanobacteria. Phylogenetic estimates constructed with bacteria, plastids, and eukaryotic genomes also suggest that plastids are most closely related to cyanobacteria.
- DNA sequence analysis and phylogenetic estimates suggests that nuclear DNA contains genes that probably came from the plastid.
- Some proteins encoded in the nucleus are transported to the organelle, and both mitochondria and plastids have small genomes compared to bacteria. This is consistent with an increased dependence on the eukaryotic host after forming an endosymbiosis. Most genes on the organellar genomes have been lost or moved to the nucleus. Most genes needed for mitochondrial and plastid function are located in the nucleus. Many originate from the bacterial endosymbiont.
- Plastids are present in very different groups of protists, some of which are closely related to forms lacking plastids. This suggests that if chloroplasts originated de novo, they did so multiple times, in which case their close similarity to each other is difficult to explain. Many of these protists contain "secondary" plastids that have been acquired from other plastid-containing eukaryotes, not from cyanobacteria directly.
- Among the eukaryotes that acquired their plastids directly from bacteria (known as Primoplantae), the glaucophyte algae have chloroplasts that strongly resemble cyanobacteria. In particular, they have a peptidoglycan cell wall between their two membranes.
- These organelles' ribosomes are like those found in bacteria (70s).
- Proteins of organelle origin, like those of bacteria, use N-formylmethionine as the initiating amino acid.

# Secondary Endosymbiosis
Primary endosymbiosis involves the engulfment of a bacterium by another free living organism. Secondary endosymbiosis occurs when the product of primary endosymbiosis is itself engulfed and retained by another free living eukaryote. Secondary endosymbiosis has occurred several times and has given rise to extremely diverse groups of algae and other eukaryotes. Some organisms can take opportunistic advantage of a similar process, where they engulf an alga and use the products of its photosynthesis, but once the prey item dies (or is lost) the host returns to a free living state. Obligate secondary endosymbionts become dependent on their organelles and are unable to survive in their absence (for a review see McFadden 2001).
One possible secondary endosymbiosis in process has been observed by Okamoto & Inouye (2005). The heterotrophic protist Hatena behaves like a predator until it ingests a green algae, which loses its flagella and cytoskeleton, while Hatena, now a host, switches to photosynthetic nutrition, gains the ability to move towards light and loses its feeding apparatus.
The process of secondary endosymbiosis left its evolutionary signature within the unique topography of plastid membranes. Secondary plastids are surrounded by three (in euglenophytes and some dinoflagellates) or four membranes (in haptophytes, heterokonts, cryptophytes, and chlorarachniophytes). The two additional membranes are thought to correspond to the plasma membrane of the engulfed alga and the phagosomal membrane of the host cell. The endosymbiotic acquisition of a eukaryote cell is represented in the cryptophytes; where the remnant  nucleus of the red algal symbiont (the nucleomorph) is present between the two inner and two outer plastid membranes.
Despite the diversity of organisms containing plastids, the morphology, biochemistry, genomic organisation, and molecular phylogeny of plastid RNAs and proteins suggest a single origin of all extant plastids  although this theory is still debated.

# Problems
- Neither mitochondria nor plastids can survive in oxygen or outside the cell, having lost many essential genes required for survival. This objection is easily accounted for by simply considering the large timespan that the mitochondria/plastids have co-existed with their hosts; genes and systems which were no longer necessary were simply deleted, or in many cases, transferred into the host genome instead. (In fact these transfers constitute an important way for the host cell to regulate plastid or mitochondrial activity.)