23–24 The rejection of evil arises from the psalmist’s spirit of commitment to the Lord and not from pride. This is clear from his prayer, asking for God to discern his motives and actions. This prayer arose from a situation in which evil people had accused him. Instead of directing himself to his adversaries, he raises up his voice in lament to God, who alone as the righteous Judge can discern his “heart” and “thoughts” (cf. vv. 1–4; 26:2).
The psalmist desires nothing less than conformity to God’s will; therefore he prays for God’s examination of his spiritual condition. He contrasts the two ways—the way of the world (“offensive way,” v. 24) and the way of God (“the way everlasting”). The one way leads to destruction and the other to life and fellowship with God (cf. 1:6; 16:11; Pr 12:28).
Petitions to God (vv. 23–24)
After his long, sustained prayer of thanksgiving, David turns to make some requests of God. But his requests are not what we might expect—health, riches, peace, possessions, etc.
These things, some of which are legitimate, do not enter his mind. One cannot contemplate the glory and greatness of God without being painfully aware of one’s own shortcomings. It was when Isaiah saw the Lord ‘high and lifted up’ that he cried, ‘Woe is me, for I am undone’ (Isa. 6). We have something very similar to that in these verses.
David first asks the Lord to ‘search’ him for any wicked way. Sin is such a pervasive thing that we cannot even see it all. It clings to every thought, word, and deed.
Then he asks God to know his thoughts (v. 23). The word translated ‘thoughts’ in some Bible versions carries the idea of anxious thoughts. We can easily see why David mentions this. He has been praising the God who is unlimited in knowledge and power, the one who is present everywhere. Such a God is worthy of our complete trust and devotion. But how often we fail to trust him! How often we let anxious thoughts control us rather than childlike trust in this mighty, wise God!
Finally, David asks to be led in the everlasting way (v. 24). This is the way of righteousness. It and it alone finally leads to everlasting life. The child of God has received the imputed righteousness of the Lord Jesus Christ, and, out of gratitude, seeks to live a righteous life.
139:23–24 / We now realize that the speaker’s invitation for God to search him at the psalm’s close is not a spontaneous response of piety but a reasoned surrender to God’s inescapable, all-searching presence. Earlier the speaker’s initial response was to escape; now he chooses to draw near to the God who pursues him. But why does the speaker petition God to do the very things he would do or has done in any case (note search and know in vv. 23 and 1, see in vv. 24 and 16, and lead in vv. 24 and 10 [niv “guide”])? (Note how these closing verses pick up a key verb from each of the first three strophes.) Apparently the goal is not merely to increase God’s knowledge but also to further the relationship between the speaker and his God. God has the prerogative to search the speaker, and he is now welcomed to do so. Although the speaker clearly disavows association with the wicked, he does not thereby presume to be without fault: he knows he may have anxious thoughts and offensive way[s]. The Hebrew term for the latter (ʿōṣeb) is a noun meaning either “hardship” or “idol.” The ambiguity may be intentional.
After a close reading of this psalm, we see that verses 1–6 concern not just divine omniscience but also divine searching (vv. 1–6). Verses 7–12 concern not just God’s omnipresence but also his pursuit (esp. v. 10). And verses 13–16 concern not just his omnipotence but also his personal craftsmanship and investment (vv. 13–16). The psalm expresses divine attributes in themselves and also divine loyalty to the speaker. They embody relational theology. The psalm is not a tranquil meditation on God; rather, it reflects the temptation to flee from him and is resolved by a reasoned surrender to God’s pursuit. It is an argument and confession for engaging in a relationship with God.
23. Search me, O God! He insists upon this as being the only cause why he opposed the despisers of God, that he himself was a genuine worshipper of God, and desired others to possess the same character. It indicates no common confidence that he should submit himself so boldly to the judgment of God. But being fully conscious of sincerity in his religion, it was not without due consideration that he placed himself so confidently before God’s bar; neither must we think that he claims to be free from all sin, for he groaned under the felt burden of his transgressions. The saints in all that they say of their integrity still depend only upon free grace. Yet persuaded as they are that their godliness is approved before God, notwithstanding their falls and infirmities, we need not wonder that they feel themselves at freedom to draw a distinction between themselves and the wicked. While he denies that his heart was double or insincere, he does not profess exemption from all sin, but only that he was not devoted to wickedness; for עצב, otseb, does not mean any sin whatever, but grief, trouble, or pravity—and sometimes metaphorically an idol. But the last of these meanings will not apply here, for David asserts his freedom not from superstition merely, but unrighteousness, as elsewhere it is said, (Isaiah 59:7,) that in the ways of such men there is “trouble and destruction,” because they carry everything by violence and wickedness. Others think the allusion is to a bad conscience, which afflicts the wicked with inward torments, but this is a forced interpretation. Whatever sense we attach to the word, David’s meaning simply is, that though he was a man subject to sin, he was not devotedly bent upon the practice of it.
24. And lead me, &c. I see no foundation for the opinion of some that this is an imprecation, and that David adjudges himself over to punishment. It is true, that “the way of all the earth” is an expression used sometimes to denote death, which is common to all, but the verb here translated to lead is more commonly taken in a good than a bad sense, and I question if the phrase way of this life ever means death. It seems evidently to denote the full continuous term of human life, and David prays God to guide him even to the end of his course. I am aware some understand it to refer to eternal life, nor is it denied that the world to come is comprehended under the full term of life to which the Psalmist alludes, but it seems enough to hold by the plain sense of the words, That God would watch over his servant to whom he had already shown kindness to the end, and not forsake him in the midst of his days.
Ver. 23.—Search me, O God, and know my heart: try me, and know my thoughts. Examine me, and see if I have not represented my feelings as they really are. Keep on always searching me out (comp. ver. 1), and “trying my reins and my heart” (Ps. 26:2). My desire is to be proved and tested.
Ver. 24.—And see if there be any wicked way in me; literally, any way of grief. “Ways of grief” are ways which lead to grief, which involve either bitter repentance or severe chastisement. And lead me in the way everlasting; i.e. either “the way that leadeth to everlasting life,” or “the good old way, the way that endures—the way of righteousness.” David, with all his faults, is one of those who “hunger and thirst after righteousness” (Matt. 5:6).
139:23–24. The psalm ends as it began with an acknowledgement of God searching and knowing him. Although David was determined to hold to God’s holy standard, at the same time, he knew his motives and obedience were imperfect. So, David concluded by asking that God see if there be any hurtful way in him (cf. 17:3–5) and, if so, lead him in the everlasting way—i.e., the “upright” way of God (cf. 27:11).
23. “Search me, O God, and know my heart.” David is no accomplice with traitors. He has disowned them in set form, and now he appeals to God that he does not harbour a trace of fellowship with them. He will have God himself search him, and search him thoroughly, till every point of his being is known, and read, and understood; for he is sure that even by such an investigation there will be found in him no complicity with wicked men. He challenges the fullest investigation, the innermost search: he had need be a true man who can put himself deliberately into such a crucible. Yet we may each one desire such searching; for it would be a terrible calamity to us for sin to remain in our hearts unknown and undiscovered. “Try me, and know my thoughts.” Exercise any and every test upon me. By fire and by water let me be examined. Read not alone the desires of my heart, but the fugitive thoughts of my head. Know with all-penetrating knowledge all that is or has been in the chambers of my mind. What a mercy that there is one being who can know us to perfection! He is intimately at home with us. He is graciously inclined towards us, and is willing to bend his omniscience to serve the end of our sanctification. Let us pray as David did, and let us be as honest as he. We cannot hide our sin: salvation lies the other way, in a plain discovery of evil, and an effectual severance from it.
24. “And see if there be any wicked way in me.” See whether there be in my heart, or in my life, any evil habit unknown to myself. If there be such an evil way, take me from it, take it from me. No matter how dear the wrong may have become, nor how deeply prejudiced I may have been in its favour, be pleased to deliver me therefrom altogether, effectually, and at once, that I may tolerate nothing which is contrary to thy mind. As I hate the wicked in their way, so would I hate every wicked way in myself. “And lead me in the way everlasting.” If thou hast introduced me already to the good old way, be pleased to keep me in it, and conduct me further and further along it. It is a way which thou hast set up of old, if is based upon everlasting principles, and it is the way in which immortal spirits will gladly run for ever and ever. There will be no end to it world without end. It lasts for ever, and they who are in it last for ever. Conduct me into it, O Lord, and conduct me throughout the whole length of it. By thy providence, by thy word, by thy grace, and by thy Spirit, lead me evermore.
139:23–24. David concluded this psalm with a prayer for God to search and test him (cf. 26:2) in order to prove his loyalty, thus showing that he was not like the wicked mentioned in 139:19–22. The verb “to search,” is also used in verse 1 in a statement about God. David asked God to test him as a refiner tests metal. Since God knows everything (cf. vv. 1–6) He would also know David’s anxious thoughts (the same Heb. word is rendered “anxiety” in 94:19). God would also know if the psalmist had any offensive way (lit., “way of pain,” i.e., pain caused by being afflicted for wrongdoing). Such an examination David was convinced, would yield evidence of his loyalty. The Lord in His leading would then preserve his life (everlasting, ‘ôlām, probably means prolonged life) here as he followed the Lord.
All believers who come to understand the attributes of God discussed in this psalm find them a great source of comfort, and a great prompting to obey Him.
139:23, 24 The Psalm closes with a prayer that has perennial suitability for all God’s people, a prayer that will never die as long as there are sinning saints on earth. It asks the Mighty God to thoroughly search and know the heart, to carefully test and know the thoughts or anxieties. It asks Him to expose every wicked way in order that it might be confessed and forsaken. And finally it asks Him to lead him in the way everlasting.
It is not the challenge of a person protesting his innocence or righteousness. Rather it is the confession of one who has been in the presence of the Lord and is convicted of his own sinfulness. He realizes that he is not cognizant of all his iniquities and wants the Lord to point them out so they can be dealt with effectively.
 VanGemeren, W. A. (2008). Psalms. In T. Longman III & D. E. Garland (Eds.), The Expositor’s Bible Commentary: Psalms (Revised Edition) (Vol. 5, p. 964). Grand Rapids, MI: Zondervan.
 Ellsworth, R. (2006). Opening up Psalms (pp. 127–128). Leominster: Day One Publications.
 Hubbard, R. L. J., & Johnston, R. K. (2012). Foreword. In W. W. Gasque, R. L. Hubbard Jr., & R. K. Johnston (Eds.), Psalms (p. 487). Grand Rapids, MI: Baker Books.
 Calvin, J., & Anderson, J. (2010). Commentary on the Book of Psalms (Vol. 5, pp. 223–224). Bellingham, WA: Logos Bible Software.
 Spence-Jones, H. D. M. (Ed.). (1909). Psalms (Vol. 3, p. 315). London; New York: Funk & Wagnalls Company.
 Rydelnik, M., Vanlaningham, M., Barbieri, L. A., Boyle, M., Coakley, J., Dyer, C. H., … Zuber, K. D. (2014). Psalms. In The moody bible commentary (p. 873). Chicago, IL: Moody Publishers.
 Spurgeon, C. H. (n.d.). The treasury of David: Psalms 120-150 (Vol. 6, pp. 265–266). London; Edinburgh; New York: Marshall Brothers.
 Ross, A. P. (1985). Psalms. In J. F. Walvoord & R. B. Zuck (Eds.), The Bible Knowledge Commentary: An Exposition of the Scriptures (Vol. 1, pp. 892–893). Wheaton, IL: Victor Books.
 MacDonald, W. (1995). Believer’s Bible Commentary: Old and New Testaments. (A. Farstad, Ed.) (p. 772). Nashville: Thomas Nelson.