How hydrostatic equilibrium works:

idealgas-anim.gif (14182 bytes) Gas pressure increases with increasing temperature. (From Nick Strobel.  Go to his site at www.astronomynotes.com for the updated and corrected version.)
Pressure (outward) and gravitational (inward) forces balance in the sun In the sun, the pressure from the hot gas counterbalances the gravity from the interior mass.
Lower pressure results in shrinking of the sun and an increase in pressure If the pressure is less than needed to balance the gravity, that part of the sun shrinks. The result is the gas temperature increases (by the gas laws) and the pressure increases. (From Nick Strobel Go to his site at www.astronomynotes.com for the updated and corrected version.)
Diagram of hydrostatic equilibrium This balancing of pressure (outward) and gravity (inward) is called hydrostatic equilibrium). (figures from J. Schombert, http://zebu.uoregon.edu/~js/ast121/lectures/lec22.html

 

 

 

Drawing of pressure/temperature equilibrium The sun is also in thermal equilibrium -- the rate of energy production in its core is matched to the rate at which it is losing energy at its surface: