Magma or lava is the molten form of rocks where intense heat turns them into hot magma. This is semi fluid and is in the subsurface. This magma can come out and produce lava and this also intrude in the joints or into the parent rock which is called dykes or sills. Igneous rocks are of two types according to the place where they forms i.e. intrusive and extrusive.
Intrusive
Intrusive rocks are those which are formed in the subsurface by direct cooling of the magma with overburden pressure. These rocks cools down gradually thereby giving time for minerals forming larger crystals. These are also called plutonic rocks. Intrusive rocks possess greater hardness than that of the volcanic rocks, this is because of the gradual cooling example are Granite, Gabbro and Peridotite.
Extrusive
Extrusive or volcanic rocks are formed by the lava when it erupts from the subsurface. As in the open air and release of overburden pressure they cools rapidly and produces smaller crystals. The examples of volcanic rocks are Rhyolite, volcanic glass and many more.