Nothing in the first eighteen verses prepares a reader for this turn. The sharpest shift in the psalm falls at verse 19, from the gentle close of the earlier verses to 19"Oh that you would slay the wicked, O God!" with no transition at all. Then two questions follow. 21"Do I not hate those who hate you, O LORD? And do I not loathe those who rise up against you?" And it goes further. 22"I hate them with complete hatred; I count them my enemies."
How to receive that is debated among faithful readers, and it helps to say so instead of smoothing it over. Some hear the zeal of a man who cares more about God's honor than his own comfort. Some hear inspired honesty, a cry to bring to God and not a pattern to copy. And Jesus later taught his followers to love their enemies. The psalm itself does not settle which reading to take before it keeps going.
What it does settle is what comes next. Verses 23 and 24 are the true climax, and the verb is the same one that opened the whole poem. 23"Search me." The prayer that began as a statement about God's knowledge ends as an instrument turned on the one praying it. David asks God to use on him a knowledge God already has by nature, and what he asks for in return is exposure and correction. 24"See if there be any grievous way in me, and lead me in the way everlasting!"
David turns the searching light on himself in the very next breath, refusing to let verse 22's hatred stand as the last, comfortable word. That sequence is the point, the discipline of never letting zeal for God's justice become an excuse to stop examining our own hearts. Anger at evil is one of the easiest places for self-righteousness to hide, precisely because it feels so justified. The psalm will not let it stand unexamined, even when the anger is aimed at actual wickedness.
This is where the different readings stop being a puzzle and start being useful. Whether you hear zeal or inspired honesty in these verses, both lead to the same next step. Whatever zeal or anger you are carrying can be brought to the same God with a request that he search whether it has stayed zeal or quietly curdled into something grievous. The theological question does not have to be settled before the pastoral prayer is prayed.
Jesus carried righteous anger without sin. When he overturned the tables in the temple, his disciples remembered a psalm, "Zeal for your house will consume me" (John 2:17). And he is the one who took on what "any grievous way" deserves, so that David's closing prayer is not a demand that would condemn either of us if God answered it fully. "Search me" is safe to pray because the one asked to search is also the one who was searched, and silenced, in the sinner's place. What began in verse 1 as a fact about God's knowledge ends here as an invitation that can survive being received.
Think of the last thing that made you angry on God's behalf. Ask him to search the anger before you act on it, and see whether it is still zeal.
Prayer
Father, when righteous anger rises in us, do not let it end in quiet self-satisfaction. Search us, know our hearts, try us and know our thoughts, and show us any grievous way hiding under what feels like justified zeal. Thank you that we can pray this safely, because the one who searches us is the one who was searched in our place. Lead us in the way everlasting. In Jesus' name, amen.