A geological formation, or formation, is a body of rock having a consistent set of physical characteristics (lithology) that distinguish it from adjacent bodies of rock, and which occupies a particular position in the layers of rock exposed in a geographical region (the stratigraphic column). It is the fundamental unit of lithostratigraphy, the study of strata or rock layers.
A formation must be large enough that it can be mapped at the surface or traced in the subsurface. Formations are otherwise not defined by the thickness of their rock strata, which can vary widely. They are usually, but not universally, tabular in form. They may consist of a single lithology (rock type), or of alternating beds of two or more lithologies, or even a heterogeneous mixture of lithologies, so long as this distinguishes them from adjacent bodies of rock.
The concept of a geologic formation goes back to the beginnings of modern scientific geology. The term was used by Abraham Gottlob Werner in his theory of the origin of the Earth, which was developed over the period from 1774 to his death in 1817. The concept became increasingly formalized over time and is now codified in such works as the North American Stratigraphic Code and its counterparts in other regions.
Geologic maps showing where various formations are exposed at the surface are fundamental to such fields as structural geology, allowing geologists to infer the tectonic history of a region or predict likely locations for buried mineral resources.
The boundaries of a formation are chosen to give it the greatest practical lithological consistency. Formations should not defined by any criteria other than lithology. The lithology of a formation includes characteristics such as chemical and mineralogical composition, texture, color, primary depositional structures, fossils regarded as rock-forming particles, or other organic materials such as coal or kerogen. The taxonomy of fossils is not a valid lithological basis for defining a formation. 
The contrast in lithology between formations required to justify their establishment varies with the complexity of the geology of a region. Formations must be able to be delineated at the scale of geologic mapping normally practiced in the region; the thickness of formations may range from less than a meter to several thousand meters.
Geologic formations are typically named after a permanent natural or artificial feature of the geographic area in which they were first described. The name consists of the geographic name plus either "Formation" or a descriptive name. Examples include the Morrison Formation, named for the town of Morrison, Colorado, and the Kaibab Limestone, named after the Kaibab Plateau of Arizona. The names must not duplicate previous formation names, so, for example, a newly designated formation could not be named the Kaibab Formation, since the Kaibab Limestone is already established as a formation name. The first use of a name has precedence over all others, as does the first name applied to a particular formation.
As with other stratigraphic units, the formal designation of a formation includes a stratotype which is usually a type section. A type section is ideally a good exposure of the formation that shows its entire thickness. If the formation is nowhere entirely exposed, or if it shows considerably lateral variation, additional reference sections may be defined. Long-established formations dating to before the modern codification of stratigraphy, or which lack tabular form (such as volcanic formations), may substitute a type locality for a type section as their stratotype. The geologist defining the formation is expected to describe the stratotype in sufficient detail that other geologists can unequivocally recognize the formation.
Although formations should not be defined by any criteria other than primary lithology, it is often useful to define biostratigraphic units on paleontological criteria, chronostratigraphic units on the age of the rocks, and chemostratigraphic units on geochemical criteria, and these are included in stratigraphic codes.
The concept of formally defined layers or strata is central to the geologic discipline of stratigraphy, and the formation is the fundamental unit of stratigraphy. Formations may be combined into groups of strata or divided into members. Members differ from formations in that they need not be mappable at the same scale as formations, though they must be lithologically distinctive where present.
The definition and recognition of formations allow geologists to correlate geologic strata across wide distances between outcrops and exposures of rock strata. Formations were at first described as the essential geologic time markers, based on their relative ages and the law of superposition. The divisions of the geological time scale were described and put in chronological order by the geologists and stratigraphers of the 18th and 19th centuries.
Geologic formations can be usefully defined for sedimentary rock layers, low-grade metamorphic rocks, and volcanic rocks. Intrusive igneous rocks and highly metamorphosed rocks are generally not considered to be formations, but are described instead as lithodemes.
"Formation" is also used informally to describe the odd shapes (forms) that rocks acquire through erosional or depositional processes. Such a formation is abandoned when it is no longer affected by the geologic agent that produced it. Some well-known cave formations include stalactites and stalagmites.