Wiktionary
n. A new musical composition built out of an already existing one, most often a new melody overlaid on a familiar harmonic structure. An important part of the development of bebop. Contrafacts are not to be confused with musical quotations, which comprise borrowing rhythms or melodies from an existing composition.
Wikipedia
In jazz, a contrafact is a musical composition consisting of a new melody overlaid on a familiar harmonic structure. Contrafact can also be explained as the use of borrowed chord progressions.
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 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.
In spite of its usefulness, the term "contrafact" has not won wide acceptance in Western classical theory.