The cantata was commissioned by the Wiener Tonkünstler-Societät, and first performed on 13 March 1785 in the Vienna Burgtheater.
Most of the music is derived from the unfinished Great Mass in C minor, K. 427 (1782–83), although two arias ("A te, fra tanti affanni" and "Fra l'oscure ombre funeste") and a cadenza for the last movement ("Chi in Dio sol spera") were newly composed for the work.
The theme of the work is based on the Psalms and the First Book of Samuel of the Old Testament.
The text was previously attributed to Lorenzo Da Ponte, following a report by Vincent Novello.
[2] However, it is now known that the text is taken from Italian translations of the Psalms by Saverio Mattei [it] (1742–95).