Psalm 17:1–15 (ESV)

1 Hear a just cause, O LORD; attend to my cry! Give ear to my prayer from lips free of deceit!

The setting of Psalm 17:1–15 is not clear. Yet it is clear that David is in trouble, much like he often was during the days of King Saul. It seems as though he was the victim of false accusations: he cries out that he has spoken truthfully, with lips free of deceit (Psalm 17:1), and he observes about his opponents that with their mouths they speak arrogantly (Psalm 17:10). Furthermore, he speaks of his enemies as like a lion eager to ambush him (Psalm 17:12). This bears a resemblance to Saul’s pursuit of David, during which time David pleaded his cause to the Lord as judge, to deliver him from Saul’s hand (see especially 1 Samuel 24:12–15). He could maintain that in righteousness he did nothing violent to bring harm to Saul, the Lord’s anointed, and did nothing underhanded to overthrow Saul’s kingship. On these matters, David maintained innocence, righteousness, praying for the Lord to use his sword to deliver David from the wicked (see 1 Samuel 26:9–10). Thereby, David showed Saul’s pursuit and persecution to be wicked. And, though this cannot be pushed too far, the fact that the superscription above Psalm 18:1–50 mentions David’s being delivered from the hand of Saul and all his enemies suggests that Psalm 17:1–15 should be understood as coming amid David’s perseverance in the face of Saul’s persecution.1

Lastly, David’s prayer to God to visit him by night (Psalm 17:3), and his hope to see God’s face when I awake (Psalm 17:15), may point toward an evening prayer.