Metamorphic rocks are formed by the action of heat and pressure on pre-existing rocks, mainly sedimentary rocks, which are changed by that action.
Local or contact metamorphism, extending over a few metres or tens of metres, can be caused near the Earth's surface by a flow or sill. It happens quickly.
Large-scale regional metamorphism happens only at great depths, and may extend over very large distances: it involves heat, pressure, and a long time scale.
When sedimentary rocks are heated and compressed for long periods, limestone changes to marble, sandstone changes to quartzite and shale changes to slate.
In some cases, fossils formed in a sedimentary rock may still be recognizable after the rock has undergone metamorphism, confirming its sedimentary origins.