English Basic Explanation - Chapter 18
This chapter records the "Shira" (song, or poem) that David composed "on the day when God saved him from the hand of all his enemies and from the hand of Shaul" (verse 1). Rashi and other commentators explain that David composed this special poem, which is recorded with minor variations also in the Book of Shemuel II (chapter 22), towards the end of his life, after having successfully battled against Israel's enemies. Much of David's reign was spent waging daring wars against some of Israel's most bitter and dangerous foes, including the Pelishtim, Edom, Moav, Amon and Aram. The eighteenth chapter of Tehillim was written to express David's feelings as he reflected in old age on the truly remarkable victories to which he led Benei Yisrael during his period of rule. From the aforementioned introduction to this chapter ("and from the hand of Shaul"), it is clear that he celebrates here also his escape from King Shaul who had set out to kill him. As we would expect, David attributes his unlikely survival and then his spectacular military success to God's might and power, rather than to his own.
In verses 8-16, David makes reference to supernatural occurrences, such as violent earthquakes (verse 8), unusual darkness (verse 12), hail mixed with fire (verses 13-14), and destructive "arrows" and lightening (verse 15). Rashi explains these descriptions as references to the miracles of the Exodus and the splitting of the Sea of Reeds. David thus emphasizes that it was the same God who performed miracles for his ancestors in Egypt that rescued him from his foes. The Ibn Ezra, however, interprets these references as figurative descriptions of the supernatural speed and drama with which the tides were turned upon David's enemies. Against all odds and with no plausible explanation, David's foes, who were far more numerous and powerful than he, collapsed before him – a miracle that David allegorically depicts in supernatural terms.
In the middle of this chapter, in verses 20-25, David digresses from his descriptions of salvation to emphasize that all this came to him due to his piety and strict compliance with God's laws. These verses should not be understood as an expression of arrogance. Humility does not require ignoring the truth about one's virtues; David recognizes the extent of his loyalty to God and points to his faithful devotion as the reason for his having earned His favor.
Towards the end of this Psalm (verses 38-46), David emphasizes that God not only saved him from his vicious enemies, but granted him complete triumph to the point where they came under his unquestioned authority. So much so, he emphasizes, that even "a nation who did not know me" became subservient to him. This accurately depicts the drastic transformation David effected during his period of rule, as he once and for all, after many years of instability, secured Israel borders and established the kingdom as the most powerful nation in the region. In the Psalm's final verse, he praises God for acting so kindly to "His king" and "His Messiah," referring, of course, to himself, adding a prayer that this state of peace and security should endure forever – "for David and offspring, for all times."