A planetary nebula is an emission nebula consisting of an expanding glowing shell of ionized gas ejected during the asymptotic giant branch phase of certain types of stars late in their life. This name originated with their first discovery in the 18th century because of their similarity in appearance to giant planets when viewed through small optical telescopes, and is otherwise unrelated to the planets of the solar system. They are a relatively short-lived phenomenon, lasting a few tens of thousands of years, compared to a typical stellar lifetime of several billion years.
At the end of the star's life, during the red giant phase, the outer layers of the star are expelled via pulsations and strong stellar winds. Without these opaque layers, the hot, luminous core emits ultraviolet radiation that ionizes the ejected outer layers of the star. This energized shell radiates as a planetary nebula.
Planetary nebulae play a crucial role in the chemical evolution of the galaxy, returning material to the interstellar medium that has been enriched in heavy elements and other products of nucleosynthesis (such as carbon, nitrogen, oxygen and calcium). In more distant galaxies, planetary nebulae may be the only objects that can be resolved to yield useful information about chemical abundances.