He almost didn't get the job - but on April 22, 1723, Leipzig city officials named the composer from Eisenach director of St. Thomas Boy Choir. Bach would go on to show his rebellious side at the venerable school.
The office of "Thomascantor" - director of the St. Thomas Boys Choir in Leipzig - has existed since 1518. To the present day, there have been 33 "Thomas" cantors. Bach was the 17th in this line of musical luminaries.
His predecessor had died in the summer of 1722. But the city's leaders proved choosy and were after a Leipzig native for the post. They originally sought out Georg Philipp Telemann, at that time music director in Hamburg. But Telemann's employers upped his salary as an incentive to stay.
Leipzig's city council arrived at Johann Christoph Graupner as a second choice. He was known as a fine man with good musical sensibilities, but Graupner's boss also didn't want to let him go.
"Since we cannot get the best, then we will have to settle for average," concluded councilman Abraham Christoph Plaz.
One of the "mediocre" candidates in contention was Johann Sebastian Bach, then serving as orchestra director at the small court in Cöthen.
Three days ahead of the vote, Bach agreed he would not leave Leipzig without permission by the city authorities and to maintain "good order in the churches" by not writng compositions that were too long - should he get the job at all.
Ultimately his candidacy was supported with a unanimous vote. But then he had to prove that he understood orthodox Protestant theology despite having working beforehand at a court informed by Calvinism - a worldview seen as heretical in Lepizig.
There were other obstacles. Bach's predecessor had complained that his choristers had scabies and that their singing was suffering as a result. The school building - in which Bach and his family were supposed to live - was falling apart. The stairs could be scaled only with great difficulty, and parts were missing. Furthermore, Bach's colleagues reported seeing rats and mice in the building.
However, at least the building where Bach was to live was renovated before he moved in.
Disputes with the authorities
In Leipzig, Bach continued his astonishing level of productivity. From week to week, he composed a new cantata, and around 100 such works were written in just the first two years of his time in office. His great passions were also performed in Leipzig.
However, one year after he began his tenure as cantor, he was already in trouble with church authorities. After Bach demanded a say in choosing who was accepted to the St. Thomas School, the church reduced his salary. He was so frustrated that he began looking around for new jobs, but there were scarcely any that would have made sense for him to take.
New rector, fewer conflicts
In 1730, Johann Matthias Gesner became head of the school. Bach knew him from his time in Weimar. The new rector ordered that the building be renovated and expanded the curriculum to include the natural sciences - in accordance with Enlightenment thinking.
Gesner released Bach from the duty of teaching Latin. At least during the four years before Gesner moved on to the city of Göttingen, Bach was able to concentrate on the music for which he would eventually become world famous.
And, gradually, the "third choice" Johann Sebastian Bach went on to become the most famous cantor of St. Thomas' Church in Leipzig.