1. Thermal pressure: The intense heat generated by nuclear fusion in the star's core creates a tremendous outward pressure. Think of it like a giant, hot balloon. The hotter the gas, the more it pushes outwards.
2. Radiation pressure: The photons (light particles) produced by nuclear fusion also exert an outward force. This force is particularly significant in massive stars.
These two forces counter the inward pull of gravity, which is constantly trying to crush the star. This balance between outward pressure and inward gravity is what allows stars to maintain their size and stability for billions of years.
It's a delicate equilibrium. If the outward pressure weakens, for example, if the star runs out of fuel for fusion, gravity takes over, causing the star to collapse. This can lead to a variety of dramatic events, such as supernovae or the formation of black holes.