Due to the troubles of the Thirty Years' War it seems he was not immediately placed as a pastor, and thus moved to Berlin where he worked as tutor in the family of an advocate named Andreas Barthold.
In September 1651, Gerhardt received his first ecclesiastical appointment as the new Probst at Mittenwalde (a small town near Berlin).
He also sponsored a series of conferences between the Lutheran and Reformed clergy in the hopes of having them arrive at some consensus, but the result was the opposite: the more the two sides argued, the further apart they found themselves.
His sermons and devotional writings were so free from controversy that many among the Reformed attended his services, and the wife of the Elector, Louisa Henrietta, was a great admirer of him and his hymns.
The citizens of Berlin petitioned to have him restored, and owing to their repeated requests an exception to the edict was made for Gerhardt, although his conscience did not allow him to retain a post which, appeared to him, could only be held on condition of a tacit repudiation of the Formula of Concord.
Ironically the edict was withdrawn a few months later, although by this time his patroness, Electress Louisa Henrietta had died as well and so he was still without a position.
Many of his best-known hymns were originally published in various church hymn-books, as for example in that for Brandenburg, which appeared in 1658; others first saw the light in Johann Crüger's Geistliche Kirchenmelodien (1647) and Praxis pietatis melica.
[1] The life of Gerhardt has been written by Roth (1829), by Langbecker (1841), by Schultz (1842), by Wildenhahn (1845) and by Bachmann (1863); also by Kraft in Ersch's und Gruber's Allg.
Johann Sebastian Bach used several single stanzas of Gerhardt's hymns in his church cantatas, motets, Passions and Christmas Oratorio.
The hymn "Ich hab in Gottes Herz und Sinn" is the base for Bach's chorale cantata BWV 92.