In general, the formation and evolution of the Solar System happened when a cloud of interstellar dust and gas collapsed under the influence of gravity to form the Sun and planetesimals, and eventually the planets. This gravitational accretion led to the formation of the rocky planets and the gas giants.