As gravity compresses the core of a protostar, the temperature goes higher and higher. Eventually the temperature is high enough that the star starts fusing hydrogen into helium. When the outward pressure produced by the heating of the gas by fusion energy balances gravity, a stable star is formed.