The English word fugue, in French fugue, in Italian fuga, is originated from Latin (also fuga). Its root is to be found in the Latin word fugere (to flee) and fugare (to chase).
In music, fugue is a compositional procedure. In a fugue, there is a main musical theme (also called the subject) and it is simultaneously imitated by other melodic lines, called counterpoints. A fugue can be written for one instrument only, like piano, or more.
The origins of this compositional technique is in the middle ages, and its original form is the canon. In this, the chasing instruments (or voices) are repeating the main melody a few beats behind. This genre became more dominant in the Renaissance-era and fully accepted in the Baroque, especially because of J.S.Bach.
There is a basic structure to the fugue with standard elements.
A. Subject. This is the opening or in other words the exposition. The exposition introduces the central melody (the subject) that serves as a template for the later joining melodies.
B. Answer. This is a copy or almost exact copy of the exposition. If the answer is exactly the same, only payed in a different key, it is called the real answer. If the answer is modified, it is called tonal answer. If the answer accompanies the subject throughout the fugue in inversion (upside down), it is called countersubject.
C. Episodes. Once the subject and the answers are introduced, the episodes can follow. These modulatory passages are often (but not necessarily) based on the subject. They serve as means to modulate between different keys.
D. Further entries. Over the course of a fugue some entirely new subjects or modulated ones can enrich the music.
E. Stretto. A composer can intensify the music by layering subjects on each other in a way, where new entries are started before the current one finishes. They tend to appear at the end of the compositions.
F. Coda. This material closes the composition.
Examples of great fugue music can be J.S.Bach’s The Well-Tempered Clavier or The Art of the Fugue, and the finale of Beethoven’s Hammerklavier piano sonata.