Planets are believed to form in protostellar discs as a natural by-product of star formation. These discs are made of the same material as the star itself, gas and dust.
Solid components of the disc stick together, forming bigger and bigger objects until a core of about 15 Earth masses is formed (Bodenheimer and Pollack, 1986). The protoplanet can then start to accrete gas to form a gas giant.
Type I migration
The protoplanetary disc interacts with newly formed protoplanets. Density waves are excited in the disc both interior and exterior to the planet. The waves carry angular momentum and produce a torque on the planet that can lead to planetary migration (Goldreich and Tremaine, 1979). The direction of migration depends on the exact disc model. In most cases, the outer torque is bigger than the inner one. Thus the planet migrates inwards. This effect is called type I migration. The timescale on which the planet migrates can be short and planets might be in danger of spiralling into the star within the lifetime of the protoplanetary disc.
Type II migration
If the planet is massive enough, it can perturb the density profile of the disc and open a gap. For most disc models about a Jupiter mass is needed to clear a gap. The process is similar to the gaps opening in Saturn’s rings with moons orbiting inside. The planet still interacts with the disc and migrates (type II migration).
Type III migration
In the type III regime, the surface density distribution in the co-orbital region is asymmetric, leading to a large torque which is able to cause the planet to fall inwards on a timescale much shorter than the disc evolution time obtained for type II migration.