The solar system formed approximately 4.6 billion years ago from clouds of dust and gas that were disrupted by astrophysical events. The shock wave began squeezing and clumping the clouds into a dense mass.
As a result, the gravity of these clumps increased, which attracted more mass. The density increased and heated through frictional forces, resulting in a solar nebula, generally thought by astronomers to be a stellar nursery. The gravitational-attracted mass struck the center of the nebula unevenly, creating a rotational effect. Eventually the center reached critical mass, initiated nuclear fusion and became the sun. The remaining mass flattened out into an accretion disc surrounding the new star, clumping to become the planets of the solar system.