1To you, Lord, I call;
You are my Rock,
do not turn a deaf ear to me.
For if You remain silent,
I will be like those who go down to the pit.
2Hear my cry for mercy
as I call to You for help,
as I lift up my hands
toward Your Most Holy Place.
3Do not drag me away with the wicked,
with those who do evil,
who speak cordially with their neighbors
but harbor malice in their hearts.
4Repay them for their deeds
and for their evil work;
repay them for what their hands have done
and bring back on them what they deserve.
5Because they have no regard for the deeds of the Lord
and what His hands have done,
He will tear them down
and never build them up again.
6Praise be to the Lord,
for He has heard my cry for mercy.
7The Lord is my strength and my shield;
my heart trusts in Him, and He helps me.
My heart leaps for joy,
and with my song I praise Him.
8The Lord is the strength of His people,
a fortress of salvation for His anointed one.
9Save your people and bless Your inheritance;
be their shepherd and carry them forever.
The former part of this Psalm is the prayer of a saint militant and now in distress (v. 1-3), to which is added the doom of God's enemies (v. 4, 5). The latter part of the Psalm is the thanksgiving of a saint triumphant, and delivered out of his distresses (v. 6-8), to which is added a prophetical prayer for all God's faithful loyal subjects (v. 9).
So that it is hard to say which of these two conditions David was in when he penned it. Some think he was now in trouble seeking God, but at the same time preparing to praise him for His deliverance, and by faith giving Him thanks for it beforehand. Others think he was now in triumph, but remembered, and recorded for his own and others' benefit, the prayers he made when he was in affliction, that the God’s mercy might relish the better, when it appeared to be an answer to them.