A magma chamber is a large underground pool of liquid rock found beneath the surface of the Earth. The molten rock in such a chamber is under great pressure, and given enough time, that pressure can gradually fracture the rock around it creating outlets for the magma. If it finds a way to the surface, then the result will be a volcanic eruption; consequently many volcanoes are situated over magma chambers. Magma chambers are hard to detect, and most of the known ones are therefore close to the surface of the Earth, commonly between 1 km and 10 km under the surface. In geological terms, this is extremely close to the surface, although in human terms, it is considerably deep underground.
Magma rises through cracks from beneath and across the crust because it is less dense than the surrounding rock. When the magma cannot find a path upwards it pools into a magma chamber. Magma chambers are commonly built up incrementally, by successive horizontal or vertical magma injections. Influx of new magma causes reaction of pre-existing crystals and the pressure in the chamber to increase.
The residing magma starts to cool, with the higher melting point components such as olivine crystallizing out of the solution, particularly near to the cooler walls of the chamber, and forming a denser conglomerate of minerals which sinks (cumulative rock). Upon cooling, new mineral phases saturate and the rock type changes (e.g. fractional crystallization), typically forming gabbro, diorite, tonalite and granite or gabbro, diorite, syenite and granite. If magma resides in a chamber for a long period, then it can become stratified with lower density components rising to the top and denser materials sinking. Rocks accumulate in layers, forming a layered intrusion. Any subsequent eruption may produce distinctly layered deposits, for example the deposits from the 79 AD eruption of Mount Vesuvius include a thick layer of white pumice from the upper portion of the magma chamber overlaid with a similar layer of grey pumice produced from material erupted later from lower down in the chamber.