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 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.

In 1750 when Bach began to suffer from blindness before his death in July, BWV 666 and 667 were dictated to his student and son-in-law Johann Christoph Altnikol and copied posthumously into the manuscript.

Only the first page of the last choral prelude BWV 668, the so-called "deathbed chorale", has survived, recorded by an unknown copyist.The piece was posthumously published in 1751 as an appendix to the Art of the Fugue, with the title "Wenn wir in höchsten Nöthen sein" (BWV 668a), instead of the original title "Vor deinen Thron tret ich hiermit" ("Before your throne I now appear").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.