Planets formed in the Solar Nebula from the slow accretion of small dust particles (via electrostatic forces) into 1-10 km size planetesimals. Movie
Formation of the Terrestrial Planets
In 100,000 years, planetesimals up to 10 km in size would have formed.
The accretion continues, but fueled by the gravitational attraction of
the biggest planetesimals: The big keep getting bigger swallowing
up smaller planetesimals near its orbit. The growing young planet
absorbs the mass and the orbital energy of all the smaller objects,
circularizing (averaging out) the final orbit.
Perhaps a hundred Planetary Embryos form, with Moon masses (1/10th Earth). They interfere with each other's orbits. This mixes up the differing planet chemistries created based on distances from the Sun. More importantly, the embryos collide! This process creates the few final planets, when all embryos have been assimilated in 10 m.yrs.
Formation of the Jovian Planets
Jupiter and Saturn contain much of the lighter elements found in the
Sun (H, He). They accumulated via rocky planetesimals which were able
to integrate FROST (water ice) into their cores. Once
they were 5-10x Earth, their mass attracted the light elements,
Jupiter an additional ~300x Earth and Saturn an additional ~100x Earth mass.
Uranus and Neptune, being much farther out in
the Solar System, may have formed their central cores too late, after
most of the H and He gas in the Solar Nebula had been lost. They only
accumulated a small amount of gas beyond their rocky-ice cores (final masses
of just 14.5 and 17x Earth).