A fantasia, also called a fantasy or fantasie, is an improvisatory work that rarely follows the rules of any musical form.
The term "fantasia" was first used in the 16th century to refer to an imaginative musical "idea" rather than a compositional genre. The instrumental fantasia imitated the vocal motet, or a polyphonic musical setting of a Latin text.
Below is an excerpt from Henry Purcell’s Fantasia No. 4 in G minor, Z. 735 for viols (bowed, stringed instrument of the 16th-18th centuries). Look for places where the performers have opportunities for improvisation. In addition, notice where there are points of imitation (repeated entrances in different voices) that can also be found in motets.