His condition became so bad that he was comitted to St. Albans Insane Assylum. In God's providence the doctor who tended him there was a Christian man. This doctor loved Cowper and continually held out hope to Cowper, despite Cowper's insistence that he was beyond hope. It is through the influence of this doctor that Cowper was converted, and found the gospel to be the thing that would sustain him through his ongoing depression, which he would battle with for the rest of his life.
Immediately I received the strength to believe it, and the full beams of the Sun of Righteousness shone upon me. I saw the sufficiency of the atonement He had made, my pardon sealed in His blood, and all the fullness and completeness of His justification. In a moment I believed, and received the gospel ... Whatever my friend Madan had said to me, long before, revived in all its clearness, with demonstration of the spirit and power. Unless the Almighty arm had been under me, I think I should have died with gratitude and joy. My eyes filled with tears, and my voice choked with transport; I could only look up to heaven in silent fear, overwhelmed with love and wonder.
(Gilbert Thomas, William Cowper and the Eighteenth Century, p. 132.)