The Toccata and Fugue in F major, BWV 540, is an organ work written by Johann Sebastian Bach, potentially dating from the composer's time in Weimar, or in Leipzig.
No firm date can be established for the composition, and it has even been conjectured that the 2 parts were composed separately, with the toccata being a potentially more mature piece. Williams however describes that the differing Affekt of the two parts does not pose any problem to the hypothesis that the whole work was composed at the same period. This conception of "complementary movements" was even a favourite of Bach's, and the dramatic nature of the toccata as contrasted to the counterpoint of the fugue should, as Peter Williams writes, "not be misunderstood as mere discrepancy". Because of the range of the pedal parts, the toccata may have been written for a performance, around 1713, at the Weißenfels organ, with its pedal going up to F.
The Toccata (as a prelude) is proportionally the largest of all Bach's works in the format of prelude-fugue. It is often treated as a show piece, with the ensuing fugue omitted. The Toccata's rhythmic signature suggests a passepied or a musette, although the large scale of the movement does not support these characterizations.
Nor does the harmonic complexity of the composition; 45 measures after the second pedal solo there is a dominant chord which resolves deceptively to the third-inversion secondary dominant of the Neapolitan chord. In particular, the doubled root is found to move outward in contrary chromatic motion to a major 9th; in the bass by a descending half tone, far from the expected fifth. Bach implements this deceptive cadence three times in the piece; it would not become idiomatic until Chopin and Tchaikovsky.
The bravura of the F major toccata, with its pedal solos and manual virtuosity, contrasts with the sober opening of the Fugue. Both represent two diverse aspects of Italian influence: the motoric rhythms and sequential passagework of the Toccata, and the traditional alla breve counterpoint of the Fugue, with its chromaticism, harmonic suspensions, and uninterrupted succession of subjects and answers. These techniques are very similar to those used in the "Dorian" Toccata and Fugue in D minor, BWV 538.