Magma is superheated molten rock beneath Earth’s surface.
It is a mixture that may contain liquid rock, crystals, and dissolved gases such as water vapor, carbon dioxide, and sulfur dioxide. Magma forms when mantle or crustal rocks partially melt because of increasing temperature, decreasing pressure, or the addition of water and other volatiles.
When magma reaches the surface through a volcanic vent, it is called lava. This distinction is based on location, not on a completely different chemical substance. Magma can cool underground to form intrusive igneous rocks such as gabbro, diorite, and granite, or erupt and form volcanic rocks such as basalt and rhyolite.
Its composition strongly affects behavior. Low-silica basaltic magma is generally more fluid, while high-silica rhyolitic magma is more viscous and can trap gases more effectively, contributing to explosive eruptions.