It’s often said when discussing prayer that God always answers: yes, no, or wait. The question is this: are there biblical examples of God saying “no” for any other reason besides sin of the pray-er, the pray-er’s forefathers, or the prayer beneficiary? I’ve been running through it in my head, and every single example that I’m coming up with initially, if God said “no”, there seems to be a significant sin problem.
Firstly, the notion that God will absolutely not answer the prayers of someone who has sin in his/her life is a misconception. Its flip-side counterpart is the assumption that evil is happening in one’s life, because he has sinned. Now, there are natural consequences to living irresponsibly, sinfully, foolishly… whatever one wants to call it. However, God is not vindictive. He is just, and his mercy is fully reconciled with his justice. God is answering prayers of both the lost and the wayward every day. He answers their prayers to be rescued, whether by degree or fully redeemed in Jesus Christ. Furthermore, God does not hold the sins of the father against the children (Ezekiel 18:20), though parents can make their children’s lives like hell all on their own.
- David was told “no” regarding the building of the temple… he could prepare for it, but it was Solomon’s to build (1 Chron. 17:3-6).
- David also was told “no” regarding the life of his child, and that was clearly after David had been forgiven (2 Sam. 12:18-20).
- The liberated demoniac of Gadara asked Christ for the privilege of becoming one of his following Disciples, but the Lord Jesus refused him by saying he should stay among his own people in order to be a witness for Jesus (Mark 5:18-20). That was about God’s plan for him.
- The missionaries of Acts wanted to go to Asia, but the Holy Spirit forbade it (Acts 16:6). This is a mystery of God’s will.
- Paul was told “no” by God regarding his “thorn in the flesh,” so that God’s grace could be proven sufficient for him (2 Cor. 12:8-9).
- And, if we are sharp students, we can also see that the Lord Jesus was told “no” by the Father when he prayed “let this cup pass from me,” but thankfully that scene was about Jesus’ showing us how to surrender to the Father’s will by saying, “nevertheless, not my will but yours be done” (Luke 22:42).
To expound on the line of thinking you are trying to highlight, let me address you this way:
In Ps. 66:18 David writes an answer, which corresponds to your doubts. Please be sure to read the context and the many translations of the verse, because good scholars vary on how best to communicate in english what David was saying in Hebrew. http://biblehub.com/psalms/66-18.htm
Also note that he was addressing “all who fear (reverentially love) God” (v. 16).
Above all, please note the kind of prayer David made. He was ‘between a rock and a hard place’ before experiencing the deliverance which led him to pen this psalm. So, Psalm 66 is the result of the old “cry for help” prayer where somebody says things like, “Dear God, if you get me out of this, then I’ll _____.” Hahaha! But, God is so good that he hears these kind of prayers when the petitioner is repentant while crying out (ex. Jehoshaphat in 2 Chron. 18:31).
In times past, I have answered the question of “God won’t hear you, if…” by saying, “Be honest with your heart.” Do we really need to labor over whether we are reserving heart-space for a particular sin we enjoy? This is the same as Romans 13:14 which instructs us to make no plans to satisfy fleshly desires (http://biblehub.com/romans/13-14.htm). In other words, the one who cares nothing for God’s ways—or, who plans to do wrong and/or has no desire of changing in order to please the Lord—cannot be expected to ask for things in God’s will or right motives, let alone get answers (James 4:2-4). David admits that God would not have heard him if David were that sort. But, one like David, the one who is in trouble and wants out of it (and has enough reverence for God to ask Him) has Ps. 66 as proof that God will do it! Hallelujah!
To be sure, God’s goodness sends “rain to fall on the just as well as the unjust” (Matt. 5:45). And, as Paul said in other places (Rom. 2:4), it is the goodness of God that leads us to repentance (which “good” I believe God is doing to the lost and wayward every day by giving them good things… even things they ask for …or by not giving them things they want).
But, this is also true: only when we delight ourselves in the Lord (his Person, will and ways) does he give us the desires of our hearts (Ps. 37:4). Whenever we live out of a carnal/worldly heart or motive, we either do not ask at all, or we are asking in order to selfishly eat up the thing requested… instead of its being the advancement of God’s kingdom. God will not say yes to that.
In conclusion, there are examples of righteous people—even Jesus Himself—who were told “No” by God, the Father.