Stellar nucleosynthesis is the process whereby most of the elements on the Periodic Table are created. Nucleosynthesis means the synthesis of new elements from the nucleons (protons and neutrons) of lighter elements. The outcome of the Big Bang at the start of the universe was a cosmic makeup of approximately 80% hydrogen gas and 20% helium. This process is called the Big Bang nucleosynthesis, or occasionally, the primordial nucleosynthesis, and it took about three minutes. Other types of nucleosynthesis include stellar nucleosynthesis, which takes place in stars over billions of years, and supernova nucleosynthesis, which happens in a matter of seconds.
The gas coalesced into stars, which fuse atomic nuclei, producing tremendous amounts of light and heat and producing heavier elements in the process. In stars about the mass of the Sun or smaller, energy is primarily produced using the proton-proton chain reaction. The proton-proton chain reaction takes place in temperatures between 10 and 30 megaKelvins and at pressures found in the center of stars the mass of the Sun or smaller. During the reaction, hydrogen atoms are fused into deuterium, which are then fused into Helium-3. Then the atoms follow one of three possible paths to produce helium, and the reaction is over. The reaction can take as long as 109 years, which explains why our Sun is still around.
The proton-proton chain is a type of hydrogen burning, the nucleosynthetic process where stellar hydrogen is converted to helium. Another hydrogen-burning process, important in stars more massive than the Sun, is the CNO (carbon-nitrogen-oxygen) cycle. The CNO cycle uses carbon, nitrogen, and oxygen as catalysts for the star to fuse four protons into a helium nuclei. After carbon is initially formed, it is converted to nitrogen, then carbon again, then nitrogen again, then oxygen, then nitrogen, then back to carbon, and the cycle continues.
Eventually most of the hydrogen in the star is consumed, and the helium burning begins. This happens through either the alpha process or the triple alpha process. If a star is massive enough, it will keep fusing together heavier and heavier elements through the carbon burning process, neon burning process, oxygen burning process, and silicon burning process, until it builds up a core of iron that weighs 1.44 solar masses. Then, because fusing iron consumes more energy than it produces, the star loses its ability to support its own weight and collapses, sometimes catastrophically as a supernova, an explosion which can take days to months. The remnant is a neutron star or a black hole.