“Light Shining out of Darkness” is a 1773 poem and hymn lyric by William Cowper, which is commonly better known in hymn settings as "God Moves in Mysterious Ways". The poem is the likely source for the phrase "God moves in mysterious ways", although the first line of the poem actually runs "God moves in a mysterious way His wonders to perform; He plants His footsteps in the sea And rides upon the storm." The poem, the last hymn text that Cowper wrote, was written following his attempted suicide while living at Olney. John Newton published the poem the next year in his Twenty-six Letters on Religious Subjects; to which are added Hymns (1774).
Tunes
Cowper's poem is usually set to the hymn tune Dundee, from Scottish Psalter (1615) Alternate tunes include Belmont, by William Gardiner (1812), London New, from Psalms (Edinburgh 1635), Manoah, as arranged by Henry Greatorex (1851), St. Anne, by Chapel Royal composer William Croft (1708) as well as Union, from Select Number of Plain Tunes, by Andrew Law (1781).