According to the University of Michigan, the primitive Earth did not have an atmosphere until gases were released from the planet's interior. Fast-moving gases and massive volcanic eruptions led to the creation of two distinct yet equally important atmospheric layers.
According to NASA, Earth's earliest atmosphere was likely composed of only hydrogen and helium, two of the most abundant substances in the universe. These gases also composed the gassy disk around the Sun from which the Earth and all surrounding planets were formed. When the atmosphere first formed, Earth was extremely hot and inhospitable to the life that currently exists on it. Hydrogen and helium molecules hovering over Earth's surface eventually took on such velocity that they escaped the gravitational pull of Earth and drifted into space. This process resulted in the formation of the first layer of the Earth's atmosphere.
NASA explains that the second atmospheric layer was formed over billions of years due to massive volcanic eruptions. At this time, there were far more volcanoes spread out across the Earth's surface, which resulted in gases from the Earth's interior being released globally. These gases included steam, carbon dioxide and ammonia. Eventually, the ammonia molecules were broken up by sunlight and left nitrogen and hydrogen behind, causing the formation of the atmospheric conditions that exist today.