As the magma rises, bubbles start to form from the gas dissolved in the magma. The gas bubbles exert tremendous pressure. This pressure helps to bring the magma to the surface and forces it in the air, sometimes to great heights.
It's sort of like the bubbles of gas in a bottle of soda. Before you open the soda you don't see many bubbles because the pressure in the bottle keeps the gas dissolved in the soda. When you open the bottle the pressure is released and the gas bubbles leave the soda. If you shake up the bottle first, the soda gets pushed out by the bubbles of gas as they rush out.