Acting alone, gravity would cause stars to collapse completely, but as long as energy is produced at their centers by nuclear fusion (the joining of atomic nuclei to form new elements, as in a hydrogen bomb), the star is heated and puffed up.
CNN: Why gamma-ray burst shocked scientists