The Solar System is thought to have emerged from the gravitational collapse of a huge cloud of gas and dust around 4.5 billion years ago. The cloud was probably several light-years across and gave rise to the birth of several stars, including our own Sun.
After the creation of the new stars, they were left with spinning clouds of gas and dust around them, known as proto-planetary discs. The image on the right shows such dust clouds around newly formed stars in the Orion Nebula, and it is the material within these clouds that is used to create planet systems around the stars over the next several million years.
The planets are believed to have formed by a process known as accretion, whereby dust grains in orbit around the Sun started to collide with each other to form clumps of between one and ten metres in diameter. These then collided to form larger bodies (planetesimals) of roughly 5 km in size; then gradually increased by further collisions at roughly 15 cm per year over the course of the next few million years.
The inner Solar System was too warm for lighter elements, such as water and all gases, to exist, and so the planetesimals which formed there were relatively small and made of heavy elements like rock and iron. These rocky bodies eventually became the terrestrial planets - Mercury, Venus, Earth and Mars.
Further out in the outer Solar System it was much cooler, and so gases like Hydrogen and Helium could exist. It is no surprise therefore that the giant planets in the outer Solar System are mostly made of gas - Jupiter, Saturn, Uranus and Neptune.
Many astronomers think that the Asteroid Belt, between the planet Mars and Jupiter, is the left-over remains of the Sun's proto-planetary disc that was unable to come together to form a planet, because of the strong gravitational
influence of Jupiter.