Most of Bach's works for the organ date from his years in Weimar (1708-1717). This period witnessed a tremendous development in his compositional style, particularly in the realm of the freely composed preludes or toccatas and fugues -- those not based on preexisting chorales.
The fugue and toccata of BWV 540 were each published individually during the eighteenth century; many believe the toccata to have been written apart from, and probably after, the fugue -- a possibility that has led many to perform the pieces alone. This is not difficult to justify, for each is a self-contained masterwork. Together, they form what many believe to be Bach's best composition in the prelude and fugue genre, and they have both enjoyed great popularity.
It is possible the toccata was written for an organ other than the one Bach used in Weimar; the highest pedal pitch in the piece was not available on that organ. It was, however, to be found in Weissenfels and at one of the churches in Köthen. The piece is immense and, at 450 measures in length, can hardly be heard as a "prelude." Bravura passages for both the hands and feet take the listener through various harmonic areas in this expansive work, which derives its rhythmic drive from a persistent, Italianate figure. Neapolitan sixths, averted cadences, and sequences contribute to the tension of a sustained climax in the second half of the toccata.
The fugue is actually a double-fugue that presents a stark contrast to the preceding toccata. Harmonic daring characterizes the piece: an unresolved dissonance in the second measure sets the precedent for numerous other such instances, including accented non-harmonic tones. After the four-voice exposition -- with both a subject and countersubject -- has run its course, a complete counter-exposition begins. Instead of continuing with an independent episode, Bach writes another fugal section, with a new, lively subject, featuring entries that move through minor keys, including the dominant minor. Throughout this second fugue, the pedal is absent, infusing the succession of entries and episodes with a sense of anticipation, or preparation, of something to come. This turns out to be just the function of the section when the first subject and its countersubject return, almost stealthily, in the midst of the contrapuntal texture. The return of the first fugue does not assert itself, however, until its first answer, which is accompanied in the pedal (finally) by the subject of the second fugue. Bach truncates and distorts this second subject as six more entries of the first subject float around the tonic before a final statement, with a powerful pedal entry, closes the piece.