It was used in several musical settings, including the chorale cantata by Johann Sebastian Bach, Erhalt uns, Herr, bei deinem Wort, BWV 126.
[2] Luther wrote the hymn probably in 1541 when a prayer service was held in Wittenberg against the perceived danger of the Turks[3] when Ferdinand of Austria lost most of Hungary to the Ottoman Empire at Siege of Buda.
In Klug's hymnal Geistliche Lieder it was titled a "A hymn for the children to sing against the two arch-enemies of Christ, and His Holy Church, the Pope and the Turks"[3] ("Ein Kinderlied, zu singen wider die zween Ertzfeinde Christi und seiner heiligen Kirchen, den Bapst und Türcken").
[3] In hymnals at the time of Johann Sebastian Bach, "Erhalt uns, Herr, bei deinem Wort" this combination of five stanzas was often continued by Luther's German version of Da pacem Domine (Give peace, Lord, 1531), and a second stanza to it, as follows:[6][7] The sixth stanza is a prayer for peace, beginning "Verleih uns Frieden gnädiglich, Herr Gott, zu unsern Zeiten" (Grant us peace graciously, Lord God, in our time).
[8] In modern editions of "Erhalt uns, Herr, bei deinem Wort", the line against the Pope and the Turks was replaced by a more neutral wording against God's enemies in general.