This is one of the few hymns that we know Martin Luther wrote both the lyrics and melody. It summarizes Luther’s views on church music - the lyrics should preach the Gospel. While some, like Calvin, took this to mean only quotations from the Bible were fit for congregational singing, Luther believed that paraphrases and lyrics whose inspiration is from scripture were acceptable. The inspiration for this hymn was Psalm 46:
God is our refuge and strength,
an ever-present help in trouble.
Therefore we will not fear, though the earth give way
and the mountains fall into the heart of the sea,
though its waters roar and foam
and the mountains quake with their surging.
The melody that Luther wrote was surely included in a hymnal from 1529, but the oldest extant copy dates from 1531. The original rhythm was quite choppy. The more even version we sing dates from the 1700s. This hymn has spread far and wide, including in Bach’s Cantata 80, Mendelssohn’s Symphony No. 5, and Meyerbeer’s opera Les Huguenots.