Low mass stars, such as our own sun, spend the majority of their lifetime (billions of years) on the main sequence where they maintain hydrostatic equilibrium by transmuting hydrogen into helium in their stellar cores through the process known as nuclear fusion. When all of the hydrogen is consumed, the gravitational force will compress the core further, raising it to a temperature high enough for it to begin fusing helium, which temporarily prevents further collapse. The increased temperature also triggers a shell of hydrogen to begin fusing around the star's core in the aptly named process called hydrogen shell burning. All of this increased radiation causes the star's envelope to expand outward into its new stage of evolution, the red giant phase.
In the red giant phase and beyond, the star will start a complicated set of fusion reactions which changes the structure significantly. Eventually, when all its nuclear fuel is consumed, the core will lack the proper conditions to continue fusion burning. It is a highly complicated state of affairs, because stars of different masses will have different core temperatures, and hence differing abilities to burn each element in its interior. The mathematics which govern these processes are highly non-linear differential equations, and it is gratifying that the results that these equations yield, match superbly the features of the HR diagram.
Eventually, gravity will force the core of the star to contract while the outer layers of the former star will puff out into a planetary nebula. The core of the star will collapse until quantum mechanical processes set in, which stabilizes the star once more. The Pauli Exclusion Principle, which states that two identical particles, electrons in this case, cannot have identical quantum mechanical properties (particle spin, energy, angular momentum etc...) turns out to affect the structure of the star greatly. The pressure that results is called electron degeneracy pressure, (we discuss this in more detail in section 3.3 of the wiki pertaining to Type Ia supernovae) and it stops the star from further collapse when its radius is about the same as the earth. When the star reaches this new state it is said to become a white dwarf. Without any further interaction the white dwarf will exist indefinitely as it radiates away any residual thermal energy left over from its younger, more active days.
Stars with masses greater than about eight times that our sun share some similarities with their low-mass counterparts, but also diverge greatly in the way that they evolve off the upper main sequence. Like low mass stars, high mass stars will consume all of their hydrogen in the core, and then begin fusing helium while burning hydrogen in a thin shell around the helium core. This heating also causes the star to expand, but its luminosity and size now dwarf that of the red giants, putting them into another spectral type even more luminous called the red supergiants.
These stars will continue fusing successively heavier elements in their cores, but they can go beyond the ability to fuse carbon and oxygen in their core, all the way up to iron. Iron is the most tightly bound nucleus of all the elements, so fusing elements beyond this actually requires an input of energy, instead of extracting energy that would normally prop the star up against its own gravity. At this point the star's core will collapse beyond the point of a white dwarf, since the core has so much mass that even electron degeneracy pressure cannot halt the relentless onslaught of gravitational. The core collapses further until the electrons combine with the protons. A super dense ball of neutrons remains that is approximately the size of New York City. Once again the Pauli exclusion principle kicks in and prevents the neutrons from occupying the same quantum mechanical states, yielding what is known as neutron degeneracy pressure. There may be instances where gravity will be stronger than even neutron degeneracy pressure, and the core may collapse into a black hole.
At the time core collapse, something spectacularly violent occurs known as a Supernova. These are among the most violent explosions in the universe, one in which the energy produced can be greater then the net sum of all the energy produced throughout the star's previous lifetime. Supernovae seem like harbingers of death, but life as we know it today would be impossible without them. Stars can only fuse elements up to iron in their fiery cores, but all of the heavier elements can be formed in supernovae, as their temperatures are so high that even the heavy elements can be synthesized. As these massive stars explode, their entire contents are pushed outward enriching their galaxy with heavy elements that can now contribute to successive epochs of stellar and planetary formation.
Below is a great video from www.spacetelescope.org that will help your understanding of how stars evolve during their lifetime, using the HR diagram as a visual aid. Note how all of the spectral classes of the HR diagram are intimately related the evolution of stars off the main sequence. The time spent in the later phases of evolution of stars is almost negligible when compared to their lifetime on the main sequence, where they comfortably and leisurely fuse hydrogen into helium.