Rock produced by the cooling of magma within the earth (plutonic rock) or on the surface (volcanic rock).