Here is a brief outline of the current theory of the events in the early history of the solar system:
- A cloud of interstellar gas and/or dust (the “solar nebula”) is disturbed and collapses under its own gravity. The disturbance could be, for example, the shock wave from a nearby supernova.
- As the cloud collapses, it heats up and compresses in the center. It heats enough for the dust to vaporize. The initial collapse is supposed to take less than 100,000 years.
- The center compresses enough to become a protostar and the rest of the gas orbits/flows around it. Most of that gas flows inward and adds to the mass of the forming star, but the gas is rotating. The centrifugal force from that prevents some of the gas from reaching the forming star. Instead, it forms an “accretion disk” around the star. The disk radiates away its energy and cools off.
- First brake point. Depending on the details, the gas orbiting star/protostar may be unstable and start to compress under its own gravity. That produces a double star. If it doesn’t …
- The gas cools off enough for the metal, rock and (far enough from the forming star) ice to condense out into tiny particles. (i.e. some of the gas turns back into dust). The metals condense almost as soon as the accretion disk forms (4.55-4.56 billion years ago according to isotope measurements of certain meteors); the rock condenses a bit later (between 4.4 and 4.55 billion years ago).
- The dust particles collide with each other and form into larger particles. This goes on until the particles get to the size of boulders or small asteroids.
- Run away growth. Once the larger of these particles get big enough to have a nontrivial gravity, their growth accelerates. Their gravity (even if it’s very small) gives them an edge over smaller particles; it pulls in more, smaller particles, and very quickly, the large objects have accumulated all of the solid matter close to their own orbit. How big they get depends on their distance from the star and the density and composition of the protoplanetary nebula. In the solar system, the theories say that this is large asteroid to lunar size in the inner solar system, and one to fifteen times the Earth’s size in the outer solar system. There would have been a big jump in size somewhere between the current orbits of Mars and Jupiter: the energy from the Sun would have kept ice a vapor at closer distances, so the solid, accretable matter would become much more common beyond a critical distance from the Sun. The accretion of these “planetesimals” is believed to take a few hundred thousand to about twenty million years, with the outermost taking the longest to form.
- Two things and the second brake point. How big were those protoplanets and how quickly did they form? At about this time, about 1 million years after the nebula cooled, the star would generate a very strong solar wind, which would sweep away all of the gas left in the protoplanetary nebula. If a protoplanet was large enough, soon enough, its gravity would pull in the nebular gas, and it would become a gas giant. If not, it would remain a rocky or icy body.
- At this point, the solar system is composed only of solid, protoplanetary bodies and gas giants. The “planetesimals” would slowly collide with each other and become more massive.
- Eventually, after ten to a hundred million years, you end up with ten or so planets, in stable orbits, and that’s a solar system. These planets and their surfaces may be heavily modified by the last, big collision they experience (e.g. the largely metal composition of Mercury or the Moon).
Note: this was the theory of planetary formation as it stood before the discovery of extrasolar planets. The discoveries don’t match what the theory predicted. That could be an observational bias (odd solar systems may be easier to detect from Earth) or problems with the theory (probably with subtle points, not the basic outline.)