Gait is the pattern of movement of the limbs of animals, including humans, during locomotion over a solid substrate. Most animals use a variety of gaits, selecting gait based on speed, terrain, the need to maneuver, and energetic efficiency. Different animal species may use different gaits due to differences in anatomy that prevent use of certain gaits, or simply due to evolved innate preferences as a result of habitat differences. While various gaits are given specific names, the complexity of biological systems and interacting with the environment make these distinctions "fuzzy" at best. Gaits are typically classified according to footfall patterns, but recent studies often prefer definitions based on mechanics. The term typically does not refer to limb-based propulsion through fluid mediums such as water or air, but rather to propulsion across a solid substrate by generating reactive forces against it (which can apply to walking while underwater as well as on land).
Due to the rapidity of animal movement, simple direct observation is rarely sufficient to give any insight into the pattern of limb movement. In spite of early attempts to classify gaits based on footprints or the sound of footfalls, it was not until Eadweard Muybridge and Étienne-Jules Marey began taking rapid series of photographs that proper scientific examination of gaits could begin.
Milton Hildebrand pioneered the contemporary scientific analysis and the classification of gaits. The movement of each limb was partitioned into a stance phase, where the foot was in contact with the ground, and a swing phase, where the foot was lifted and moved forwards. Each limb must complete a cycle in the same length of time, otherwise one limb's relationship to the others can change with time, and a steady pattern cannot occur. Thus, any gait can completely be described in terms of the beginning and end of stance phase of three limbs relative to a cycle of a reference limb, usually the left hindlimb.
Gaits are generally classed as "symmetrical" and "asymmetrical" based on limb movement. It is important to note that these terms have nothing to do with left-right symmetry. In a symmetrical gait, the left and right limbs of a pair alternate, while in an asymmetrical gait, the limbs move together. Asymmetrical gaits are sometimes termed "leaping gaits", due to the presence of a suspended phase.
The key variables for gait are the duty factor and the forelimb-hindlimb phase relationship. Duty factor is simply the percent of the total cycle which a given foot is on the ground. This value will usually be the same for forelimbs and hindlimbs unless the animal is moving with a specially trained gait or is accelerating or decelerating. Duty factors over 50% are considered a "walk", while those less than 50% are considered a run. Forelimb-hindlimb phase is the temporal relationship between the limb pairs. If the same-side forelimbs and hindlimbs initiate stance phase at the same time, the phase is 0 (or 100%). If the same-side forelimb contacts the ground half of the cycle later than the hindlimb, the phase is 50%.
Gait choice can have effects beyond immediate changes in limb movement and speed, notably in terms of ventilation. Because they lack a diaphragm, lizards and salamanders must expand and contract their body wall in order to force air in and out of their lungs, but these are the same muscles used to laterally undulate the body during locomotion. Thus, they cannot move and breathe at the same time, a situation called Carrier's constraint, though some, such as monitor lizards, can circumvent this restriction via buccal pumping. In contrast, the spinal flexion of a galloping mammal causes the abdominal viscera to act as a piston, inflating and deflating the lungs as the animal's spine flexes and extends, increasing ventilation and allowing greater oxygen exchange.
Animals typically use different gaits in a speed-dependent manner. Almost all animals are capable of symmetrical gaits, while asymmetrical gaits are largely confined to mammals, who are capable of enough spinal flexion to increase stride length (though small crocodilians are capable of using a bounding gait). Lateral sequence gaits during walking and running are most common in mammals, but arboreal mammals such as monkeys, some opossums, and kinkajous use diagonal sequence walks for enhanced stability. Diagonal sequence walks and runs (aka trots) are most frequently used by sprawling tetrapods such as salamanders and lizards, due to the lateral oscillations of their bodies during movement. Bipeds are a unique case, and most bipeds will display only three gaits—walking, running, and hopping—during natural locomotion. Other gaits, such as human skipping, are not used without deliberate effort.
Hexapod gaits have also been well characterized, particularly for drosophila and stick insects (Phasmatodea). Drosophila use a tripod gait where 3 legs swing together while 3 legs remain on the ground in stance.  However, variability in gait is continuous. Flies do not show distinct transitions between gaits but are more likely to walk in a tripod configuration at higher speeds. At lower speeds, they are more likely to walk with 4 or 5 legs in stance.  Tetrapod coordination (when 4 legs are in stance) is where diagonally opposite pairs of legs swing together. Wave (sometimes called a metachronal wave) describes walking where only 1 leg enters swing at a time. This movement propagates from back to front on side of the body and then the opposite. Stick Insects, a larger hexapod, only shows a tripod gait during the larval stage. As adults at low speeds, they are most likely to walk in a metachronal wave, where only 1 leg swings at a time. At higher speeds, they walk in a tetrapod coordination with 2 legs paired in swing or a metachronal wave, only moving one leg at a time. 
While gaits can be classified by footfall, new work involving whole-body kinematics and force-plate records has given rise to an alternative classification scheme, based on the mechanics of the movement. In this scheme, movements are divided into walking and running. Walking gaits are all characterized by a "vaulting" movement of the body over the legs, frequently described as an inverted pendulum (displaying fluctuations in kinetic and potential energy which are out of phase), a mechanism described by Giovanni Cavagna. In running, the kinetic and potential energy fluctuate in-phase, and the energy change is passed on to muscles, bones, tendons and ligaments acting as springs (thus it is described by the spring-mass model).
Speed generally governs gait selection, with quadrupedal mammals moving from a walk to a run to a gallop as speed increases. Each of these gaits has an optimum speed, at which the minimum calories per metre are consumed, and costs increase at slower or faster speeds. Gait transitions occur near the speed where the cost of a fast walk becomes higher than the cost of a slow run. Unrestrained animals will typically move at the optimum speed for their gait to minimize energy cost. The cost of transport is used to compare the energetics of different gaits, as well as the gaits of different animals.
In spite of the differences in leg number shown in terrestrial vertebrates, according to the inverted pendulum model of walking and spring-mass model of running, "walks" and "runs" are seen in animals with 2, 4, 6, or more legs. The term "gait" has even been applied to flying and swimming organisms that produce distinct patterns of wake vortices.