In classical music, a fugue (, from Latin fuga, meaning 'flight' or 'escape') is a contrapuntal, polyphonic compositional technique in two or more voices, built on a subject (a musical theme) that is introduced at the beginning in imitation (repetition at different pitches), which recurs frequently throughout the course of the composition. It is not to be confused with a fuguing tune, which is a style of song popularized by and mostly limited to early American (i.e. shape note or "Sacred Harp") music and West Gallery music. A fugue usually has three main sections: an exposition, a development, and a final entry that contains the return of the subject in the fugue's tonic key. Fugues can also have episodes, which are parts of the fugue where new material often based on the subject is heard; a stretto (plural stretti), when the fugue's subject overlaps itself in different voices, or a recapitulation. A popular compositional technique in the Baroque era, the fugue was fundamental in showing mastery of harmony and tonality as it presented counterpoint.
In the Middle Ages, the term was widely used to denote any works in canonic style; however, by the Renaissance, it had come to denote specifically imitative works. Since the 17th century, the term fugue has described what is commonly regarded as the most fully developed procedure of imitative counterpoint.