There are three main types of rocks: igneous, metamorphic, and sedimentary. Igneous rocks form when magma cools and hardens either below or above the surface of the Earth. Metamorphic rocks are formed from existing rocks that undergo changes due to heat and pressure in the Earth's interior. Sedimentary rocks form through the compaction and cementation of sediments such as rocks and mineral particles, skeletons, or other materials over time, usually at the bottoms of lakes and oceans.