There are two types of nuclear reactions, in which large amounts of energy are released. These reactions are nuclear fission and nuclear fusion.
Nuclear fusion, which is what happens in the sun, is the process by which multiple nuclei with Similar electric charge come together and form a heavier nucleus. During this process, a large amount of energy is released in the form of electromagnetic radiation, in this case light, and heat.
In the Sun occurs, the fusion of Hydrogen atoms. Inside the sun, because of the enormous gravitational force, pressure allows for temperatures to reach 15 million degrees Celsius; in this way, the Hydrogen atoms reach sufficient kinetic energies that allow him to approach so that, exceed the electrostatic repulsion between its protons and finally merge, giving rise to a helium atom and the conversion of a fraction of the mass, in electromagnetic radiation.
The power of the Sun is about 3.8 x10^26 watts or 3.8 x10^23 kilowatts. In other words, the Sun generates in a second the equivalent of 760,000 times the annual energy production worldwide.
It comes from a process called nuclear fusion, where smaller elements fuse to give rise to larger elements, typically hydrogen converting to helium along with energy release. It is the same principle on which hydrogen bomb works.