Oxygen had a profound effect on the evolution. Life on Earth emerged in an oxygen-free environment. Around 2.7 billion years ago, photosynthetic cyanobacteria started to produce oxygen. This caused a mass extinction of anaerobic organisms, but some bacteria used oxygen for energy production. According to the endosymbiotic theory, the mitochondria of eukaryotes derive from such bacteria; the chloroplasts of plants are descendants of cyanobacteria. During the Cambrian 'explosion' about 500 million years ago, rising oxygen levels enabled the evolution of complex animals. In later periods, fluctuations of atmospheric oxygen levels contributed to animal terrestrialization and mass extinction events, and facilitated the evolution of large insects and dinosaurs.