To the Chief Musician. A Psalm of David the servant of the LORD, who spoke to the LORD the words of this song on the day that the LORD delivered him from the hand of all his enemies and from the hand of Saul. And he said:
I will love You, O LORD, my strength. The LORD is my rock and my fortress and my deliverer; my God, my strength, in whom I will trust; my shield and the horn of my salvation, my stronghold.
The superscript before verse 1 describes the setting for David’s composition of this psalm, which is also recorded in 2 Samuel 22. “This song was composed when God delivered David from the hand of Saul during David’s wilderness exploits. Perhaps an incident such as the one recorded in 1 Sam. 23:24-28 provided the impetus for David to write this ‘song of testimony’” (NKJV Study Bible, note on 2 Samuel 22:1).
God had promised that David would become king, and David trusted Him, despite being hunted by King Saul. David describes God’s power and faithfulness in terms of the wilderness he had been hiding in and the armor he used.
“David calls God my rock and my castle. … The two epithets are borrowed from the natural character of Palestine, where steep and almost inaccessible rocks afford protection to the fugitive, as David had often found at the time when Saul was pursuing him (1 Sam. 24:23; 22:5). But while David took refuge in rocks, he placed his hopes of safety not in their inaccessible character, but in God the Lord, the eternal spiritual rock” (Keil-Delitzsch Commentary, note on 2 Samuel 22).
For more about God’s protection and armor, see “Put on the Armor of God.”