Hydrogen atoms are compressed together by the enormous gravitational force of the sun, causing them to fuse int a helium atom (which is heavier than hydrogen), subatomic particles and enormous release of atomic energy. The attached picture shows the sequence of the main reaction at the core of the sun.