Psalm 7 begins with a familiar phrase in the psalms thus far. The psalmist declares, “in you do I take refuge” (v. 1). This phrase is found frequently in the psalms and refers to the entrusting of one’s life to God’s care in the midst of trials. In this psalm, the phrase is found at the very beginning rather than at the end (as in Ps 2:12 and Ps 5:11) and it is also the first time it is used personally in relating to God. Therefore, David’s aim in this psalm is to actively take refuge in God.
Also, notice how David repeatedly addresses God by his covenant name: “O LORD my God” (vv. 1, 3). The original word for LORD in the Hebrew is Yahweh, the name revealed to those whom he has brought into intimate relationship. This address is also very personal, accenting on the unique nature of the psalm as a prayer rooted in deep intimacy and trust in God. This is how the people of God should always pray, especially in times of trial (as exemplified in this psalm). May I pray in this way at all times!
David is constantly in trouble, but in this situation there is a sense in which he may have wronged someone who is innocent, and perhaps even a friend (v. 4). If this were absolutely true, he is resolved to endure their punishment (v. 5). However he is convinced that he has not wronged anyone, so he leaves the situation up to God to take vengeance (v. 6). He then expands this personal prayer to include all of the righteous and the wicked, leaning upon the just judgment of God to “let the evil of the wicked come to an end” and “establish the righteous” (v. 9).
But who is righteous before God? Are we to infer from David’s words in verse 8 (“judge me, O LORD, according to my righteousness“) that David himself is righteous? No. Rather, he asks God to judge him on the basis of his own integrity in this particular matter of whether or not he wronged an innocent person. The basis of this psalm is not his own righteousness. Rather, he is able to pray this psalm because he takes refuge in God (v. 1). This is also seen in the conclusion of the psalm: “I will give to the LORD the thanks due to his righteousness” (v. 17).