Igneous rocks form when magma (molten rock) cools and crystallizes, either at volcanoes on the surface of the Earth or while the melted rock is still inside the crust. All magma develops underground, in the lower crust or upper mantle, because of the intense heat there.