The Great Eighteen Chorale Preludes, BWV 651–668, are a set of chorale preludes for organ prepared by Johann Sebastian Bach in Leipzig in his final decade (1740–1750), from earlier works composed in Weimar, where he was court organist. The works form an encyclopedic collection of large-scale chorale preludes, in a variety of styles harking back to the previous century, that Bach gradually perfected during his career. Together with the Orgelbüchlein, the Schübler Chorales and the third book of the Clavier-Übung, they represent the summit of Bach's sacred music for solo organ.
Early versions of almost all the chorale preludes are thought to date back to 1710–1714, during the period 1708–1717 when Bach served as court organist and Konzertmeister (director of music) in Weimar, at the court of Wilhelm Ernst, Duke of Saxe-Weimar. As a result of encouragement from the Duke, a devout Lutheran and music lover, Bach developed secular and liturgical organ works of all forms, in what was to be his most productive period for organ composition. As his son Carl Philipp Emanuel Bach mentions in his obituary or nekrolog: "His grace's delight in his playing fired him to attempt everything possible in the art of how to treat the organ. Here he also wrote most of his organ works." During Bach's time at Weimar, the chapel organ there was extensively improved and enlarged; occupying a loft at the east end of the chapel just below the roof, it had two manual keyboards, a pedalboard and about a dozen stops, including at Bach's request a row of tuned bells. It is probable that the longer chorale preludes composed then served some ceremonial function during the services in the court chapel, such as accompanying communion.
When Bach moved to his later positions as Kapellmeister in Köthen in 1717 and cantor at the Thomaskirche in Leipzig in 1723, his obligations did not specifically include compositions for the organ. The autograph manuscript of the Great Eighteen, currently preserved as P 271 in the Berlin State Library, documents that Bach began to prepare the collection around 1740, after having completed Part III of the Clavier-Übung in 1739. The manuscript is made up of three parts: the six trio sonatas for organ BWV 525–530 (1727–1732); the Canonic Variations on "Vom Himmel hoch da komm' ich her" BWV 769 added at the same time as the chorale preludes (1739–1750); and an early version of Nun komm' der heiden Heiland (1714–1717), appended after Bach's death.