Phases of Matter
Scientists refer to matter's solid, liquid or gaseous states as the phases of matter. A substance's phase depends on both its temperature and its pressure. When a substance's temperature is high enough, the substance reaches what is known as the "critical temperature," beyond which the substance cannot be compressed into a liquid or solid because the particles have too much energy. The sun's temperatures are high enough to prevent it from becoming solid.
Gravity
The sun contains about 98 percent of all of the mass in the solar system, mostly in the form of hydrogen, along with helium and other gasses. These gasses are held together by gravity, which pulls all of the sun's matter toward its center. This gravitational pull creates the high pressure levels within the sun, which are partly responsible for its gaseous state. In addition, gravitational contractions generates some of the sun's heat energy.
Nuclear Fusion
According to NASA's Goddard Space Flight Center, the heat energy generated by this gravitational contraction in the early part of the sun's lifetime, along with the pressure of the sun's mass on its center, made it possible for nuclear fusion to occur. The sun's core is 10 million times denser than lead, and its temperature is 27 million degrees Fahrenheit. In this sphere of highly compressed gas, the nuclei of hydrogen atoms combine to form helium nuclei, releasing energy in the form of gamma rays and neutrinos. As the gamma rays move out of the sun's core, some of their energy is converted into heat, further contributing to the sun's high temperature.
Equilibrium
Scientists believe that the sun has been active for more than 4 billion years, and that it is about halfway through its life cycle. The radiant force and heat of the fusion reactions pushing outward against the sun's gravity maintain the balance of temperature and pressure that keep the sun in a gaseous state. However, even when the sun's core runs out of hydrogen fuel for nuclear fusion, other nuclear reactions will continue to generate energy within the sun.