Earth's atmosphere was formed billions of years ago primarily through the release of gases from volcanic activity. As the early Earth cooled from a molten state, volcanoes erupted, releasing large amounts of gases including carbon dioxide, water vapor, nitrogen, hydrogen, and small amounts of ammonia and methane into the atmosphere. This volcanic outgassing was the main process that introduced these gases from the Earth's interior to the atmosphere. Water vapor later condensed to form the oceans, and carbon dioxide dissolved in the oceans, reducing its levels in the atmosphere. Over time, nitrogen accumulated because it is chemically inert and stable. Oxygen was initially scarce and only started to accumulate significantly about 2.4 billion years ago due to photosynthesis by early cyanobacteria, leading to the Great Oxidation Event. The early atmosphere was thus shaped largely by volcanic gases and later biological activity altering its composition.
