Great Oxygenation Event

The Great Oxygenation Event (GOE) was the creation of free oxygen in our atmosphere. It was caused by cyanobacteria doing photosynthesis. It took a very long time, from three billion years ago to about one billion years ago.
Photosynthesis was making oxygen both before and after the GOE. Before the GOE, organic matter and dissolved iron chemically captured any free oxygen. Earth has much iron, and iron has higher solubility than its oxides, so the oceans had much dissolved iron. It became iron oxide and made huge deposits of banded iron rock from the Archaean and Proterozoic eras. When not enough iron remained to capture more oxygen, free oxygen accumulated in the atmosphere. This was the GOE.
Oxygen was toxic to most of the Earth's anaerobic inhabitants at the time. As cyanobacteria produced oxygen, and built their stromatolites, they changed the environment for other protists. Since the other protists had no way to deal with oxygen, most became extinct. Another consequence was the effect of free oxygen on atmospheric methane, a greenhouse gas. Their reaction removed the methane, and caused the Huronian glaciation. This was perhaps the longest snowball Earth episode ever. Free oxygen has been an important part of the atmosphere ever since.
Timing.
The evidence is that free oxygen was first produced by photosynthetic organisms (prokaryotic, later eukaryotic) which emitted oxygen as a waste product. These organisms lived long before the GOE, perhaps 3500 million years ago (mya). The oxygen they made would have quickly been removed from the atmosphere by the 'mass rusting' which led to the deposition of banded-iron formations. Oxygen only began to continue in the atmosphere in small quantities shortly (~50 million years) before the start of the GOE. Without a draw-down, oxygen would come to the atmosphere and stay there very quickly. At today's rates of photosynthesis (which are much greater than those in the land-plant-free Precambrian), modern atmospheric O2 levels could be produced in around 2,000 years.
Timeline: