A magma chamber is a large pool of liquid rock beneath the surface of the Earth. The molten rock, or magma, in such a chamber is less dense than the surrounding country rock, which produces buoyant forces on the magma that tend to drive it upwards.  If the magma finds a path to the surface, then the result will be a volcanic eruption; consequently, many volcanoes are situated over magma chambers.  These chambers are hard to detect deep within the Earth, and therefore most of those known are close to the surface, commonly between 1 km and 10 km down. 
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. These chambers are commonly built up over time,   by successive horizontal  or vertical  magma injections. The 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 (1) gabbro, diorite, tonalite and granite or (2) 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 in the chamber.
Another effect of the cooling of the chamber is that the solidifying crystals will release the gas (primarily steam) previously dissolved when they were liquid, causing the pressure in the chamber to rise, possibly sufficiently to produce an eruption. Additionally, the removal of the lower melting point components will tend to make the magma more viscous (by increasing the concentration of silicates). Thus, stratification of a magma chamber may result in an increase in the amount of gas within the magma near the top of the chamber,  and also make this magma more viscous, potentially leading to a more explosive eruption than would be the case had the chamber not become stratified.
Supervolcano eruptions are possible only when an extraordinarily large magma chamber forms at a relatively shallow level in the crust. However, the rate of magma production in tectonic settings that produce supervolcanoes is quite low, around 0.002 km3 year−1, so that accumulation of sufficient magma for a supereruption takes 105 to 106 years. This raises the question of why the buoyant silicic magma does not break through to the surface more frequently in relatively small eruptions. The combination of regional extension, which lowers the maximum attainable overpressure on the chamber roof, and a large magma chamber with warm walls, which has a high effective viscoelasticity, may suppress rhyolite dike formation and allow such large chambers to fill with magma. 
If the magma is not vented to the surface in a volcanic eruption, it will slowly cool and crystallize at depth to form an intrusive igneous body, one, for example, composed of granite or gabbro (see also pluton).
Often, a volcano may have a deep magma chamber many kilometers down, which supplies a shallower chamber near the summit. The location of magma chambers can be mapped using seismology: seismic waves from earthquakes move more slowly through liquid rock than solid, allowing measurements to pinpoint the regions of slow movement which identify magma chambers. 
In Iceland, Thrihnukagigur, discovered in 1974 by cave explorer Árni B. Stefánsson and opened for tourism in 2012, is the only volcano in the world where visitors can take an elevator and safely descend into the magma chamber.