Nuclear fusion is the lifeblood of stars, and an important process in understanding how the universe works. The process is what powers our own Sun, and therefore is the root source of all the energy on Earth. For example, our food is based on eating plants or eating things that eat plants, and plants use sunlight to make food. Furthermore, virtually everything in our bodies is made from elements that wouldn't exist without nuclear fusion.
How Does Fusion Begin?
Fusion is a stage that happens during star formation. This begins in the gravitational collapse of a giant molecular cloud. These clouds can span several dozen cubic light years of space and contain vast amounts of matter. As gravity collapses the cloud, it breaks up into smaller pieces, each centered around a concentration of matter. As these concentrations increase in mass, the corresponding gravitation and thereby the entire process accelerates, with the collapse itself creating heat energy. Eventually, these pieces condense under the heat and pressure into gaseous spheres called protostars. If a protostar does not concentrate enough mass, it never achieves the pressure and heat necessary for nuclear fusion, and becomes a brown dwarf. The energy rising from the fusion taking place in the center achieves a state of equilibrium with the weight of the star's matter, preventing further collapse even in supermassive stars.
Most of what makes up a star is hydrogen gas, along with some helium and a mixture of trace elements. The enormous pressure and heat in the Sun's core is sufficient to cause hydrogen fusion. Hydrogen fusion crams two hydrogen atoms together, resulting in the creation of one helium atom, free neutrons and a great deal of energy. This is the process that creates all the energy released by the Sun, including all the heat, visible light and UV rays that eventually reach the Earth. Hydrogen is not the only element that can be fused in this way, but heavier elements require successively greater amounts of pressure and heat.
Running Out of Hydrogen
Eventually stars begin to run out of the hydrogen that provides the basic and most efficient fuel for nuclear fusion. When this happens, the rising energy that was sustaining the equilibrium was preventing further condensation of the star sputters out, causing a new stage of stellar collapse. When the collapse puts sufficient, greater pressure on the core, a new round of fusion is possible, this time burning the heavier element of helium. Stars with a mass of less than half our own Sun lack the wherewithal to fuse helium, and become red dwarfs.
Ongoing Fusion: Mid-Sized Stars
When a star begins fusing helium in the core, the energy output increases over that of hydrogen. This greater output pushes the outer layers of the star further out, increasing its size. Ironically, these outer layers are now far enough from where the fusion is taking place to cool off a bit, turning them from yellow to red. These stars become red giants. Helium fusion is relatively unstable, and fluctuations in temperature can cause pulsations. It creates carbon and oxygen as byproducts. These pulsations have the potential to blow off the outer layers of the star in a nova explosion. A nova can in turn create a planetary nebula. The remaining stellar core will gradually cool off and form a white dwarf. This is the likely end for our own Sun.
Ongoing Fusion: Big Stars
Bigger stars have more mass, which means that when the helium is exhausted, they can have a new round of collapse and produce the pressure to start a new round of fusion, creating yet heavier elements. This can potentially go on until iron is reached. Iron is the element that divides elements which can produce energy in fusion from those that absorb energy in fusion: iron absorbs a little energy in its creation. Now fusion is draining, rather than creating energy, although the process is uneven (iron fusion won't be going on universally in the core). The same fusion instability in supermassive stars can cause them eject their outer shells in a manner similar to regular stars, with the result being called a supernova.
An important consideration in stellar mechanics is that all matter in the universe heavier than hydrogen is the result of nuclear fusion. Truly heavy elements, such as gold, lead or uranium, can only be created through supernova explosions. Therefore, all the substances we are familiar with on Earth are compounds built out of the debris of some past stellar demise.