Underground molten rock is referred to as magma or lava, which cools to form igneous rock. Igneous rock is important because it gives scientists important clues about what is happening inside the Earth.
Magma weighs less than rock, which allows it to flow towards the Earth's crust. The further magma is from the Earth's core, the cooler the temperature becomes. This allows magma to cool at varying speeds. When magma cools very slowly, large crystals have time to form in the igneous rock. When magma cools quickly, which happens during volcanic eruptions, the crystals are very small, having less time to form.