Magmatism is the emplacement of magma within and at the surface of the outer layers of a terrestrial planet, which solidifies as igneous rocks. Volcanism is the surface expression of magmatism.
Magmatism is one of the main processes responsible for mountain formation. The nature of magmatism depends on the tectonic setting. For example, andesitic magmatism associated with the formation of island arcs at convergent plate boundaries or basaltic magmatism at mid-ocean ridges during sea-floor spreading at divergent plate boundaries.
On Earth, magma forms by partial melting of silicate rocks either in the mantle, continental or oceanic crust.