The solar system formed around 4.5 billion years ago from a huge swirling cloud of dust. We know this because advances in technology, such as the Hubble telescope, have allowed us to look deep into space to observe the birth of stars similar to our Sun.
A pillar of dust and gas in the Eagle Nebula.
Throughout the Milky Way, and other galaxies like it, are gigantic swirling clouds of dust and gas known as nebula. It is within nebula that stars are born. Our star, the Sun, was created in one such nebula.
Something, perhaps the shock wave from an exploding supernova (dying star) triggered dust particles to be drawn together to form a dense spherical cloud. The accumulation of dust set off a chain reaction. As the core of the cloud attracted more dust, its gravitational pull increased. More and more dust was sucked in and the cloud collapsed in on itself. As this happened, the rotation of the cloud increased in speed, as happens when spinning ice skaters pull in their arms. The rotational forces at the equator of the cloud prevented dust along this plane being drawn in, causing the cloud to flatten into a disc spinning around a dense core.
As more and more mass accumulated at the centre of the disc, the temperature increased dramatically. Eventually there was enough energy to set off nuclear reactions. Hydrogen atoms fused to form helium, releasing enormous amounts of energy in vigorous bursts. This marked the birth of the Sun, although it would take between one and 10 million more years for it to settle into the main sequence star recognisable today.
A star forming region in the Orion Nebula.
The planets, and other extraterrestrial objects such as asteroids, formed in the flat plane of the spinning disc of dust. Electrostatic forces or sticky carbon coatings made dust particles stick together to form clusters, which in turn stuck together to form rocks. Mutual gravity caused these rocks to come together, eventually to form planets. This 'coming together' of material is a process known as accretion.