In music a voluntary is a piece of music, usually for an organ, that is played as part of a church service. In English-speaking countries, the music played before and after the service is often called a 'voluntary', whether or not it is titled so.
The title 'voluntary' was often used by English composers during the late Renaissance, Baroque, and Classical periods. Originally, the term was used for a piece of organ music that was free in style, and was meant to sound improvised (the word voluntary in general means "proceeding from the will or from one's own choice or consent"). This probably grew out of the practice of church organists improvising after a service.
Later, the voluntary began to develop into a more definite form, though it has never been strictly defined. During the late 17th century, a 'voluntary' was typically written in a fugal or imitative style, often with different sections. In the 18th century the form typically began with a slow movement and then a fugue. Two to four movements were common, with contrasting tempos (slow-fast-slow-fast). In the 18th century England, the word 'voluntary' and 'fuge' were interchangeable. These English style 'fuges' (or fugue) do not follow the strict theoretic form of German-style fugues. They are more related to the 'fugues' written by Italian composers of the time.
Besides the fugal type of voluntary, two other common forms developed: the trumpet voluntary and the cornet voluntary. These two were usually non-fugal, but still contained movements with contrasting tempos. These voluntaries were meant to feature the stops for which they are named. One very long example of this form of voluntary was written by Pepusch, and has 13 total movements. Several of the movements are named after organ solo stops or mixtures (bassoon, cornet, trumpet, sesquialtera, flute, twelfth, etc.).
Many composers wrote voluntaries, including Orlando Gibbons, John Blow, Henry Purcell, William Boyce, John Stanley, Handel and Thomas Arne. Often, when English music printers published continental organ music, they would, by default, title the works as 'voluntaries', though the word was not used by composers in mainland Europe. Typically, these continental works were fugues or other imitative forms.