In this short psalm, David is concerned about several enemies. He knows that the only person who can rescue him is the Lord. It is possible that when he calls God his rock (v. 1) he means a rock or natural pillar several yards high on which he could stand far above the threats of his foes. An obvious parallel would be for us to realise that we are risen with Christ, and in that way we are safe.
One aspect of his concern is that God will allow the attackers to overcome David as an expression of chastisement (v. 3). Therefore he reminds God that he is looking towards the sanctuary in which the mercy-seat was located (v. 2). The only way of escape for a believer is through the grace won for him by Jesus, which was typified by the blood of a sacrifice that was sprinkled on the mercy-seat. David could not base his argument for deliverance on his own merits, and neither can we.
In verses 4 and 5 David commits his opponents into the hands of God. On this occasion, the psalmist asks God to act in justice. This is an Old Testament example of the New Testament teaching that we should not take revenge, but leave such matters in God’s hands.
The tone of the psalm changes in verses 6 to 9. Evidently David wrote these verses later than the previous ones because now he has experienced an answer to his earnest prayers. His heart is full of praise to the God who has had mercy on him (v. 6). He realises that God provides power and protection (v. 7), and therefore the only appropriate response is thankful praise.
Having experienced personal deliverance, David is led to consider that the Lord functions in the same way with all his people (v. 8). This leads him to intercede for them (v. 9). It is not a sign of spirituality to pray only for oneself; true personal prayer will inevitably lead to intercession for others. In particular, he wants them all to know the blessing of the Shepherd’s tender care.