At first Earth was just a collection of matter—a hot ball of dust, mineral particles, and gases. The matter gradually cooled to create planet Earth.
Although Earth cooled, its temperatures still ranged beyond 2,700° Fahrenheit (1,000° Celsius). This was cool enough to produce a relatively delicate surface of basalt covering the molten rock within. Volcanic eruptions and careening asteroids frequently shattered the surface, but it would form again each time.
There was no atmosphere, or layer of gases, around Earth to speak of at the beginning. The first atmosphere was created about 4.2 billion years ago.
Volcanic eruptions and asteroids hitting Earth released carbon dioxide, nitrogen, water vapor, ammonia, and methane, plus many other gases from the material within Earth.
These gases were held in place by Earth’s gravity, creating our first atmosphere. It was not a healthy atmosphere by today’s standards, but it was enough to set life in motion.