|This article is about the current version of DF.|
Note that some content may still need to be updated.
There are four types of stone layers in Dwarf Fortress, very much based on real-life geology (see below). Stone layers are roughly homogeneous layers of rock, composed of the same kind of stone, that usually contain different ores. Each stone layer has its distinct markers and qualities; sometimes a clear dividing line can be drawn between two biomes from the stone layers underneath, sometimes not. Digging deeper, or into another local biome, will reveal differences between the layers' contents and a progression from sedimentary down to igneous. The changes are usually quite sharp; fifteen layers may be mostly quartzite, but the next thirty may be dominated by gabbro.
Most maps have at least one layer of soil at the very top, although this layer may actually run the gamut from completely non-existent to ten or more layers deep. Note that on mountainous terrain soil tends to accumulate near edges; thus you can have partial soil "layers" down the side of the mountain for quite a few z-levels.
Soil is important for three reasons: it is easily farmed (not requiring irrigation like stone does), it is easily mined (taking less time than stone), and it does not leave any loose stone behind when mined. Soil layers can contain clay and sand, if your biome has any, as well as a high chance of being an aquifer, if your biome has one. Soil layers do not contain ores or gems, and at least one layer of soil is necessary to easily establish farming. It's not recommended you establish your main fortress in soil, as it cannot be smoothed or engraved to make it visually appealing/more valuable.
The sedimentary layer has an 80% chance of being the first stone layer that appears after any soil, including any lignite or bituminous coal, if you are lucky enough to have some. Iron ore and all but one of the fluxes is common here as well, making the sedimentary layer make-or-break for steel production. Note that this layer and the igneous extrusive are mutually exclusive, and will never be found in one place. Sedimentary layers are generally where the bulwark of the fortress will find itself, will contain most of the ores marked on the embark screen as "shallow metals", and is a good choice for exploratory mining.
Note, however, that it is poor in gem content - those found in sedimentary layers are generally less valuable than those further down. Some types of sedimentary rock may contain an aquifer.
In certain regions, igneous extrusive layers replace the sedimentary layers, but when present, are not limited to the topmost layers, and can appear anywhere except the bottom-most layer. Although being made of different rocks, they are similar to sedimentary layers, with the exception being that they often indicate the presence of magma above the magma sea itself. This is always the topmost layer near volcanoes; the biggest stumbling block is that its presence means that the biome rarely contains any flux.
Can appear at any level, except the bottom-most layer, or above any sedimentary layer. Contains a small variety of vein ores, moderately valuable gems, and possibly can be marble, the one non-sedimentary flux stone. Less likely to provide iron than sedimentary, containing only small clusters of hematite or magnetite.
Igneous intrusive layers can appear at any level, except the top-most, or above any sedimentary, and the deepest and often the thickest layer will always be igneous intrusive, just above the magma sea or semi-molten rock. Gems here are generally the most valuable, on average, with the most valuable of them all, colored diamonds, found in kimberlite in gabbro layers.
In real life
Being modelled on basic geology, much of the way stone layers work in Dwarf Fortress also applies to our planet: At the surface of the world, there's a thin covering of soil, a soft mixture of minerals (the building blocks of stones), small rocks (sand, silt, clay etc.), liquids, living things and so on. Below that there's a sedimentary layer of stones; these are made of particles of minerals, organic detritus and other stuff, which, after tumbling around, end up settling down below ("sedimenting"). Those grains and particles are then glued together into new rocks ("cemented") by various processes; for example, by mineral growth of substances carried by water (similar to how stalactites grow).
Below the sedimentary layer, the rocks are subjected to heat from below, and pressure, stretching etc. from the movement of continental plates. Those forces transform them into different kinds of rocks, called metamorphic.
Further down, as things get hotter still, rocks melt into magma, which may get forced upwards, filling and often widening cracks. If the magma escapes the heat, it may cool and harden while still underground, forming the igneous intrusive ("fiery inside") rocks. If the magma rises all the way up to the surface and is expelled by a volcano, we call it lava. The lava cools down into igneous extrusive ("fiery outside") layers, which in DF replace the sedimentary layers in some biomes near volcanoes.