The sun is what is called a gravitational fusion furnace. The gravity of the sun's mass of gasses cause the pressure and the temperature in the center of the sun to reach a temperature of 15,000,000 degrees C and a pressure of about 250,000,000,000 times the pressure on the surface of the earth. At such high temperature and pressure four atoms of hydrogen fuse together to form one atom of helium.
In the center of the sun about 700 million tons of hydrogen are converted to helium every second. The resulting helium weights 5 million tons less than the hydrogen that went into making the helium. That 5 million tons of missing mass is converted into heat energy. That is the heat source of the sun.
The heat from the core of the sun causes the gasses of the sun to expand. As they expand the sun cools and the fusion reaction slows down. That cooling allows the sun to contract which heats up the sun and increases the fusion reaction. The sun, in fact, reaches an equilibrium condition where the collapse caused by gravity is exactly offset by the outward pressure of the heat produced in the core.
Even though 700 million tons of hydrogen is "burned" every second the nuclear fuel of the sun is expected to last another 3 to 6 billion years.