Rocks are classified as sedimentary, igneous, or metamorphic by their method of formation. Sedimentary rocks are formed when sediments are deposited and compacted over time. Igneous rocks are formed when magma or lava cools and solidifies. Metamorphic rocks are formed when existing rocks are changed by heat, pressure, or chemical reactions.