Igneous rocks are formed through the cooling and solidification of molten magma (underground) or lava (on the surface). This distinguishes them from sedimentary rocks (formed from compressed sediments) and metamorphic rocks (formed from existing rocks under heat and pressure). Examples include granite and basalt.