Stars are formed from dense clouds of gas and dust called nebulas. Over millions of years, the nebula collapses under gravity to form a protostar. Once the protostar's core reaches 10 million K, nuclear fusion begins and the star enters the main sequence stage. During the main sequence, internal pressure balances gravitational forces. Low and medium mass stars end as white dwarfs, then eventually black dwarfs. Massive stars may explode as supernovae, leaving behind neutron stars or black holes.