A composition, or compositional technique, in which a theme (or themes) is extended and developed mainly by imitative counterpoint.
In the opening section, the 'exposition', the main theme or 'subject' is announced in the tonic. After which the second 'voice' enters with the answer, i.e. the same theme at the dominant (or subdominant) pitch while the first may proceed to a countersubject. This procedure is repeated at different octaves until all the voices have entered and the exposition is complete. An extra statement of the subject or answer following on the exposition is called a 'redundant entry'; a set of such entries is a 'counter-exposition'.
The exposition is the only essential for the definition of a piece as a fugue, but most fugues proceed to further entries of the subject, which may be separated by 'episodes', often based on material from the exposition. The 'middle entries', normally in keys other than the tonic or dominant, may treat the theme in stretto (with overlapping entries) or vary it in some way. In 'augmentation' the note values are lengthened, in 'diminution' they are shortened; in 'inversion' the subject is upside down. A 'false entry' begins the subject but does not complete it. The final entry of the subject is usually in the tonic key.
The term fuga was used from the late Middle Ages to the early Baroque for strict imitation or canon, but fugal writing in the modern sense first appears in 16th-century vocal polyphony and in instrumental forms, including the ricercare, fantasia and canzone, derived from it. Fuga, in its present sense, appears alongside 'fantasia' in the "Tabulature nova" (1624) of Scheidt. Another kind of fugue emerged from the keyboard toccatas of Froberger and Buxtehude, and the idea of including fugal passages in the toccata led to the 'prelude and fugue' combination. J.C.F. Fischer's "Ariadne musica" (1702) is a collection of preludes and fugues in various keys which served as an example for Bach's "Well-tempered Clavier". Bach's two volumes contain some of his greatest fugues but did not exhaust his command of fugal technique. His suites, concertos and cantatas frequently combine fugue and ritornello form, and he introduced the combination of the subject and a number of counter-subjects in various vertical permutations. In the "Art of Fugue" he explored the potentialities of a single main theme in a cycle of 14 fugues, including pairs of invertible or mirror fugues, a species unique to this work. Handel's oratorio fugues, by contrast, aim at broader, more dramatic effects and tend to become homophonic at climaxes, as do his instrumental fugues.
The use of fugal material in Classical sonata-style movements was common - it has a special significance in the late piano sonatas and string quartets of Beethoven - and fugues were considered almost "de rigueur" in liturgical music throughout the 19th century. At the same time it ceased to be a normal mode of expression and became increasingly associated with academicism. Mendelssohn's E Minor fugue op.35 no.1 is a good example of the Baroque fugue seen through the eyes of a Romantic composer, and both Schumann and Brahms, with their academic leanings, made significant use of fugue in a number of works. Less predictable is Verdi's mastery of fugal technique in the "Requiem" and the final scene of "Falstaff."
In the 20th century a return to an essentially contrapuntal outlook and to Baroque ideals brought a temporary revival of interest in fugue. Hindemith's "Ludus tonalis" and Shostakovich's "24 Preludes and Fugues", both for piano, are modern equivalents of Bach's "Well-tempered Clavier", and the first movement of Bartók's "Music for Strings, Percussion and Celesta" is a notable example of the use of traditional fugal procedures in a harmonic idiom based on the tritone.