A fantasia (also fancy, fantasie and other variations according to the time, country and whim of the composer) is a piece of music that has no set form or style. As its name suggests each piece is directed more by the composer’s “fancy” or imagination than regard for any form or style. In its strictest sense, as suggested in Rousseau’s ”Dictionary of Music” (1776), a fantasia exists only as long as it is being played during composition – once it is written down, or repeated, it ceases to be a "fantasy" and becomes whatever form it now is.
Be that as it may, many composers, great and otherwise, have written fantasias in most of the forms that make up the canon of western music. Like the capriccio, a fantasia can be so-called for no other reason than that is what the composer felt like calling it at the time.
Fantasias were written for the lute in many countries from the sixteenth century – John Dowland and other English composers up to Henry Purcell also wrote songs and consort music, much of it of a whimsical nature or of sweet love, that they called fantasias or fancies.
Keyboard fantasias abound. J. S. Bach wrote examples for the organ and the famous “Chromatic Fantasy and Fugue” for domestic keyboard. Mozart’s piano fantasias are frequently performed, whilst Schubert’s “Wanderer-Fantasie” is one of the great works for the instrument. Beethoven’s two Opus 27 piano sonatas, marked “quasi una fantasia”, include the famous “Moonlight” and his “Choral Fantasy”, for piano, choir, and orchestra is considered by some as “practice” for the great "Choral Symphony" (No.9). Chopin, Schumann and Brahms are the three main Romantic era composers to have written piano fantasias.
Robert Schumann had a liking for what he called "phantasiestüche" (fantasy pieces, or works, or even "fantasy pictures") and there exist chamber pieces for various combinations of instruments under this name by this most romantic of composers.
Many fantasias are based on other music. Schubert’s “Wanderer” for example is based on one of his songs. There are instrumental “ramblings” on themes from operas such as Sarasate’s “Carmen Fantasy”. Michael Tippett wrote a “Fantasia Concentante on a Theme of Corelli” for string orchestra. Two of Vaughan Williams’ most popular works are his “Fantasia on Greensleeves” and “Fantasia on a Theme of Thomas Tallis”. He also wrote a “Phantasy Quintet” for string quartet with an extra viola. (These three pieces alone illustrate the vast variety in the music covered by the term.)
"Fantasia" is also the name of a Walt Disney animated feature film, illustrating the glories of various pieces of classical music, and mainly remembered for Mickey Mouse as Paul Dukas' "Sorcerer's Apprentice".
“Oxford Companion to Music”
“The Grove Concise Dictionary of Music”