Response to those who say that worship is accepted from everyone, no matter what his belief
Question

                Is it true that every act of worship is accepted, regardless of a person’s belief?
Praise be to Allah.Firstly:
The apparent meaning of this statement is that worship is accepted from a disbeliever just as it is accepted from a believer, and this is definitely wrong, because the worship of the disbeliever is not accepted and is not valid on his part, and he will not be rewarded for it in the hereafter, but he will benefit from good deeds in this world, as Allah will feed him in return for doing them.
Allah, may He be exalted, says (interpretation of the meaning):
“And We will regard what they have done of deeds and make them as dust dispersed”
[al-Furqaan 25:23]
“The example of those who disbelieve in their Lord is [that] their deeds are like ashes which the wind blows forcefully on a stormy day; they are unable [to keep] from what they earned a [single] thing. That is what is extreme error”
[Ibraaheem 14:18]
“But those who disbelieved - their deeds are like a mirage in a lowland which a thirsty one thinks is water until, when he comes to it, he finds it is nothing but finds Allah before Him, and He will pay him in full his due; and Allah is swift in account”
[an-Noor 24:39]
“And it was already revealed to you and to those before you that if you should associate [anything] with Allah , your work would surely become worthless, and you would surely be among the losers”
[az-Zumar 39:65]
“And whoever of you reverts from his religion [to disbelief] and dies while he is a disbeliever - for those, their deeds have become worthless in this world and the Hereafter, and those are the companions of the Fire, they will abide therein eternally”
[al-Baqarah 2:217]
“And whoever denies the faith - his work has become worthless, and he, in the Hereafter, will be among the losers”
[al-Maa’idah 5:5]
“Indeed, those who disbelieve and die while they are disbelievers - never would the [whole] capacity of the earth in gold be accepted from one of them if he would [seek to] ransom himself with it. For those there will be a painful punishment, and they will have no helpers”
[Aal ‘Imraan 3:91].
And there are many similar verses.
Muslim (214) narrated that ‘Aa’ishah said: I said: O Messenger of Allah, during the Jaahiliyyah Ibn Jud’aan used to uphold the ties of kinship and feed the poor. Will that benefit him at all? He said: “It will not benefit him, because he did not say one day, ‘Lord forgive me my sins on the Day of Judgement.’”.
And Muslim (2808) narrated that Anas ibn Maalik said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Allah does not treat the believer unjustly with regard to his good deeds. He blesses him because of them in this world and He will reward him for them in the Hereafter. As for the disbeliever, he is fed because of the good deeds that he does for the sake of Allah in this world, then when he passes on into the Hereafter, he will have no good deeds left for which to be rewarded.”.
An-Nawawi (may Allah have mercy on him) said in Sharh Muslim (17/150):
The scholars are unanimously agreed that for the disbeliever who dies in a state of disbelief there will be no reward in the hereafter, and he will not be rewarded in the hereafter for anything that he did in this world seeking to draw closer to Allah, may He be exalted.
In this hadith it clearly states that the disbeliever will be fed in this world because of the good deeds that he does, i.e., the deeds that he does seeking to draw close to Allah, may He be exalted, thereby; this refers to deeds the validity of which does not depend on the intention, such as upholding ties of kinship, giving charity, freeing slaves, offering hospitality, helping others, and so on.
As for the believer, the reward of his good deeds is stored up for him in the hereafter, and he is also rewarded for them in this world, as there is nothing to prevent him being rewarded for his good deeds both in this world and in the hereafter. This is referred to in the religious texts, and it is obligatory to believe in it.
If a disbeliever does such good deeds, then becomes Muslim, he will be rewarded for those deeds in the hereafter, according to the correct view. End quote.
Ibn Katheer said in his commentary on the first verse quoted above (3/106):
The words of Allah, “And We will regard what they have done of deeds and make them as dust dispersed” [al-Furqaan 25:23], refer to the Day of Resurrection, when Allah will bring all people to account for what they did, good or bad. Here He tells us that the deeds that these polytheists did, thinking that they would save them, will not avail them anything, because they failed to meet the prescribed conditions, either doing the deeds sincerely for Allah alone, or following the laws prescribed by Allah.
Any deed that is not sincerely for the sake of Allah alone and in accordance with the laws that He has prescribed and is pleased with, is invalid.
The deeds of the disbelievers may fail to meet either of these conditions, or they may fail to meet both of them, in which case they are even less likely to be accepted. Hence Allah, may He be exalted, says “And We will regard what they have done of deeds and make them as dust dispersed” [al-Furqaan 25:23]. End quote.
Shaykh al-Ameen ash-Shinqeeti (may Allah have mercy on him) said: Some of the disbelievers honour their parents, uphold ties with their kin, honour guests, help those who are oppressed, give relief to those who are in distress, doing all of that for the sake of Allah. These are valid righteous deeds that are in accordance with Islamic teachings and the doer may be sincere towardsAllah when doing them, but they will not benefit him before Allah on the Day of Resurrection, because Allah says (interpretation of the meaning):
“And We will regard what they have done of deeds and make them as dust dispersed”
[al-Furqaan 25:23]
“Those are the ones for whom there is not in the Hereafter but the Fire. And lost is what they did therein, and worthless is what they used to do”
[Hood 11:16]
“…their deeds are like a mirage…”
[an-Noor 24:39]
“…like ashes…”
[Ibraaheem 14:18].
And there are many similar verses.
It is proven from the Prophet (blessings and peace of Allah be upon him) that with regard to the deeds of the righteous disbeliever – such as honouring his parents, bringing relief to one who is in distress, honouring a guest, helping one who has been wronged, and upholding the ties of kinship, that are done seeking the pleasure of Allah – if a disbeliever does such righteous deeds, Allah will reward him in this world, so He will give him worldly gains such as wealth, and will grant him food and drink, and good health, but they will not bring any reward with Allah (in the hereafter).
This is proven in the hadith of the Prophet (blessings and peace of Allah be upon him) that was narrated from him by Anas, and narrated by Muslim in his Saheeh from Anas, from the Prophet (blessings and peace of Allah be upon him), that Allah feeds the disbeliever in return for his righteous deeds in this world, and He rewards him in this world, but when it comes to the hereafter, he will not have any good deeds for which to be rewarded. As for the Muslim, Allah will reward him for his good deeds in this world and stores reward for him in the hereafter.
The Qur’anic verses which indicate that the disbelievers benefit from their good deeds in this world include the following:
“Whoever desires the harvest of the Hereafter - We increase for him in his harvest. And whoever desires the harvest of this world - We give him thereof, but there is not for him in the Hereafter any share”
[ash-Shoora 42:20].
End quote from al-‘Adhb al-Muneer (5/570).
See also the answer to question no. 13350.
Secondly:
The prayer of the disbeliever may be answered, especially if he is in a state of distress or he is being wronged.
Allah, may He be exalted, says (interpretation of the meaning):
“And when they board a ship, they supplicate Allah, sincere to Him in religion. But when He delivers them to the land, at once they associate others with Him”
[al-‘Ankaboot 29:65]
“Say, ‘Who rescues you from the darknesses of the land and sea [when] you call upon Him imploring [aloud] and privately, “If He should save us from this [crisis], we will surely be among the thankful.”’
Say, ‘It is Allah who saves you from it and from every distress; then you [still] associate others with Him.’”
[al-An‘aam 6:63-64].
Ahmad (12549) narrated that Anas ibn Maalik said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Fear the prayer of the one who has been wronged, even if he is a disbeliever, for there is no barrier [between it and Allah].”
Classed as hasan by al-Albaani in as-Silsilah as-Saheehah, no. 767.
Belief is not connected to one’s social or intellectual standing, as is claimed by some of those who propagate these misguided ideas. Rather it is a serious matter, which one must affirm in the heart, seeking to draw closer to Allah, may He be exalted, no matter what a person’s environmental, physical or social circumstances.
Moreover, good deeds may be rendered invalid and rejected for various reasons, including not being in accordance with the Sunnah, or being done to show off, so how can anyone say that deeds will be accepted from everybody?!
May Allah protect us from the evils of tribulations, both apparent and hidden.
And Allah knows best.