A fugue is a contrapuntal musical composition technique in which a short melody, the subject, is introduced at the beginning and then repeated in different keys or instruments, often in combination with other musical ideas, during the exposition. The subject finally returns in its original key in the recapitulation.
The fugue evolved during the Renaissance period from the canon, in which one instrument's melody is repeated by that of another at a different pitch. It blossomed during the Baroque era, most notably with the prolific examples by Johann Sebastian Bach, and has continued to be used to various extents by composers in subsequent periods, including the Romantic era and into the current era.