The elegant and complex chiastic structure for Psa 18 is posted here.
A pair: I love You, O LORD, my strength and my deliverer, in whom I trust / Great deliverance He gives to His king, and shows mercy to His anointed.
There is a reciprocal component to the relationship between the LORD and His people. Abraham believed God, and believed in God, and so in response, God credited his faith as right-standing (Gen 15:1-6). When God made the covenant with Israel on Mt Sinai, He had a part to play, and Israel had a part to play. God’s part was to take Israel for His people, and bring them into the land He had promised to Abraham, Isaac, and Jacob; Israel’s part was to take God for their God, and obey His commandments (Exo 19-20). We see this reciprocality all through Scripture: a relationship with God is not one-sided, in which God keeps His promises and performs His word, and we do nothing.
In the A pair, David expresses His love and trust in God before any deliverance has occurred, and God responds with love in return: He shows mercy (often translated ‘lovingkindness’) to His anointed king. The emotion isn’t all on one side. And as David trusted in God to be his Deliverer, God responds in kind, and gives a great deliverance to His anointed king.
B pair: I will call upon the LORD, who is worthy to be praised / Therefore I give thanks to You, O LORD, among the Gentiles, and sing praises to Your name.
Even before the LORD had done anything to accomplish deliverance for David, David expresses how worthy the LORD is to receive praise. His praise- worthiness is a constant, as He is constant and unchanging, and His word is constant and unchanging. His praise- worthiness does not depend on changing circumstances. David understood this about God, and therefore praised Him in the face of his trouble with assurance that God deserved it no matter what happened. But of course, in the end, we find that David is praising God for accomplished deliverance and not just anticipated deliverance.
The notes to this psalm state that David spoke this psalm in the day the LORD delivered him from the hand of all his enemies, and from the hand of Saul. David lived as an outlaw pursued by Saul from shortly after he defeated Goliath when he was about 22 years old, until the death of Saul eight years later. The complete deliverance took time to accomplish, but it did not mean that God was not accomplishing it. If there is one thing we can learn from David, it is to trust God and praise Him accordingly while we wait, because the day will come when we will be praising Him for accomplished deliverance and not only anticipated deliverance.