In addition to liquid melt and crystals, magmas contain a variety of gases that are dissolved in the magma at depth in the Earth, before eruption.
As magma approaches the surface the gases come out of solution to form bubbles (see the image of a bubble-rich lava rock, below) and can be eventually released to the atmosphere.
The presence of gas in magma also has an important effect on its physcial properties. As the amount of dissolved gas increases, the viscosity greatly decreases.
Basaltic scoria (right) is full of holes. This rock shows the presence of gas bubbles, frozen in place when the magma was erupted and cooled to rock before the gas could escape.
The principal gases emitted during volcanic eruptions and their main effects on the environment are as follows:
H2O (water vapor or steam): Generally harmless, may precipitate as rain
CO2 (carbon dioxide): Adds to Earth's atmospheric CO2 budget, contributes to the greenhouse effect, and warms global climate
SO2 (sulfur dioxide): Forms sufluric acid on contact with water, harmful to skin and respiration, aerosol form contributes to global cooling
HF (hydrogen fluoride or hydrofluoric acid): Skin irritant, adheres to vegetation, poisonous if ingested (esp. hazardous to grazing livestock)
HCl (hydrogen chloride or hydrochloric acid): Skin and eye irritant, also poisonous if ingested