The solar system formed from a large cloud of dust and gas that collapsed under gravity around 4.6 billion years ago. As the cloud spun, it flattened into a disk with the sun at the center. Closer to the sun, the rocky, terrestrial planets Mercury, Venus, Earth, and Mars formed. Further from the sun, the larger gas giants Jupiter, Saturn, Uranus, and Neptune formed, along with the icy planet Pluto. The inner planets are smaller and denser, while the outer planets have thick atmospheres and are mostly made of gas.