When a star depletes its core supply of hydrogen, gravity dominates in the core and pressure dominates in the envelope.
When a star runs out of fuel it begins to contract and it eventually becomes a smaller star. The core then starts to contract and gets hotter and hotter. The upper layers then start to expand due to pressure and turns into a red giant.