Igneous rock is formed by the cooling of magma (molten rock) inside the Earth or on the surface. Sedimentary rocks are formed from the products of weathering by cementation or precipitation on the Earth's surface. Metamorphic rocks are formed by temperature and pressure changes inside the Earth.