The specific type of rock that forms when magma cools at the Earth's surface is extrusive igneous rock. Igneous rock forms when magma cools, but where the magma cools determines the type of igneous rock that forms. Igneous rock gets its name from the Greek word for fire and is so called due to the extremely hot liquid from which the rocks originate.
When magma cools at the surface, it cools rapidly and does not have time to form very large crystals. Basalt, found on the ocean floor, is an example of an extrusive igneous rock. On the other hand, magma that cools slowly beneath the Earth's surface forms rocks that contain large crystals. Geologists refer to these as intrusive igneous rocks; granite is an example of an intrusive igneous rock.