In the second portion of David’s song of deliverance, the king celebrates his blamelessness. In fact, David says, “The LORD rewarded me according to my righteousness” (2 Sam. 22:25). David understands his deliverance from Saul, Absalom, and other enemies as in some way connected to his own obedience to the Lord.
Commentators rightly note that such a claim will strike many of us as odd at best and as delusional or even heretical at worst. David, after all, did some very unrighteous things, including adultery and arranging for the death of his lover’s husband (ch. 11). How can he claim righteousness and that God rewarded him for it?
Understanding what David means by “righteousness” here gives us the answer. Put simply, the Bible distinguishes between positional and practical righteousness, or as Martin Luther wrote, between alien and proper righteousness. The first kind of righteousness is the perfect obedience God requires for our justification and eternal salvation (Lev. 18:5; Matt. 5:48). We get this righteousness from Christ—His perfect obedience is imputed to us, put on our account, when we place our faith in Him alone. This righteousness makes us positionally righteous—legally righteous in the sight of God—and it is an alien righteousness because it properly belongs not to us but to someone else, namely, Jesus Christ (1 Cor. 1:30; 2 Cor. 5:21).
The second kind of righteousness is the righteousness Scripture attributes to faithful servants of God who live lives of faith and repentance, who seek to obey His law, and who are increasing in godliness overall. Here we are not talking about sinless perfection but about the righteousness of people such as Noah, Lot, and Zechariah and Elizabeth (Gen. 6:9; Luke 1:6; 2 Peter 2:7–8). This is a practical and proper righteousness because it refers to our practice, to our obedience. It is the fruit of the Spirit’s work in us as we rely on His power and keep—albeit imperfectly—God’s commandments. This righteousness is the good-faith effort to obey the Lord.
Despite all of his sins, when we evaluate David’s life as a whole, he possessed this second kind of righteousness. That is what he appeals to in today’s passage. He was rewarded with deliverance from his enemies because he was a faithful servant of God (2 Sam. 22:21–31). Those who trust in the Lord alone are declared righteous, and they begin to practice righteousness. They will ultimately be saved from all their foes (Deut. 28:1–7; 2 Tim. 4:18).