Rocks form through three main processes: igneous, sedimentary, and metamorphic. Igneous rocks form when magma or lava cools and crystallizes. Sedimentary rocks form through the compaction and cementation of sediments over time. Metamorphic rocks were originally igneous or sedimentary rocks that were subjected to heat and pressure within the Earth, transforming their composition and structure.