A contrafact is a musical work based on a prior work. The term comes from classical music and has only since the 1940s been applied to jazz, where it is still not standard. In classical music, contrafacts have been used as early as the parody mass and In Nomine of the 16th century. More recently, Cheap Imitation (1969) by John Cage was produced by systematically changing notes from the melody line of Socrate by Erik Satie using chance procedures.
As a compositional device, it was of particular importance in the 1940s development of bop, since it allowed jazz musicians to create new pieces for performance and recording on which they could immediately improvise, without having to seek permission or pay publisher fees for copyrighted materials (while melodies can be copyrighted, the underlying harmonic structure cannot be).
Contrafacts are not to be confused with musical quotations, which comprise borrowing rhythms or melodic figures from an existing composition.
In spite of its usefulness, the term "contrafact" has not won wide acceptance in Western classical theory.
Well-known examples of contrafacts include the Charlie Parker/Miles Davis bop tune "Donna Lee," which uses the chord changes of the standard "Back Home Again in Indiana" or Thelonious Monk's jazz standard "Evidence", which borrows the chord progression from Jesse Greer and Raymond Klages's song "Just You, Just Me" (1929). Examples from the classical oeuvre include Sinfonia by Luciano Berio using samples from Mahler, George Crumb borrowing Chopin's nocturnes, or Matt A. Mason's "Heiligenstadt Echo" which takes from Beethoven's Sonata in Ab major, op. 110. The Gershwin tune "I Got Rhythm" has proved especially amenable to contrafactual recomposition: the popularity of its "rhythm changes" is second only to that of the 12-bar blues as a basic harmonic structure used by jazz composers.