Approximately 4.6 billion years ago, the solar system formed from a molecular cloud of gas and dust. Gravitational collapse created a solar nebula that contracted and flattened into a spinning protoplanetary disk with the proto-Sun at its center. Planets formed through accretion of disk material, with terrestrial planets developing in the inner region and gas giants in the outer cooler region. This process established the current structure containing the Sun, planets, moons, asteroids, and comets.