Magma is the term used for molten, or melted, rock.
Magma wells up from the deep layer of Earth called the mantle. Rock in the mantle is partly melted because of the very high temperature at that depth.
In some places, magma is closer to the surface of Earth than it is in other places. Because it is under great pressure, the magma oozes or gushes out of cracks in Earth’s surface.
To picture this, think of opening a can of soda that has been shaken. The magma is like the soda spraying out when you open the can. When magma comes to Earth’s surface, it is called lava.
The lava cools and solidifies—sometimes quickly, sometimes slowly—forming rocks.