And from these examples is Allah, the Most High’s saying,
“As for those who disbelieve – 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. Or [the state of a disbeliever is] like darkness within a vast sea which is covered by waves, upon which are waves, over which are dark clouds, some of them upon others (in darkness). When one puts out his hand [therein], he can hardly see it. And he to whom Allah has not granted light – for him there is no light.” (Surah Al-Nur:39-40)
Allah, the Most High, mentions two examples regarding the disbelievers; one example in which they are compared to a mirage – and the other, to layers of darkness on top of one another. This is because those who turn away from guidance and truth are of two types: one who mistakenly thinks he is actually on some firm basis – and when the truth finally reveals itself to him, it becomes clear to him that it was contrary to what he used to believe. This condition corresponds to the people of ignorance and the people of innovation and vain desires, who think they are on the path of guidance and knowledge and once the reality of matters are made evident, it finally becomes clear to them that they were on no firm ground whatsoever. And that their beliefs and deeds that were founded upon these (i.e. upon misguided beliefs and whims) were like a mirage that appears to the eyes of the distant observers, as water while there is no actual reality to it. Similar are the deeds which are performed for other than the sake of Allah, Exalted is he, and not according to His Commandments; the doer of these deeds thinks of them as earning him benefit while they are not at all. And it is regarding such deeds that Allah, Exalted is He has said about them,
“And We will regard what they have done of deeds and make them as dispersed as dust.” (Surah al-Furqan:23)
And reflect over Allah’s making of the mirage in the desert – a land that is barren and without buildings, trees, plants and people because the location of the mirage itself has no reality, hence this corresponds to the condition of their (i.e. the ignorant and the innovators) deeds and their hearts which are devoid of faith and guidance.
It is also worthy to ponder the underlying meaning in Allah’s saying “a thirsty one thinks is water” – (the original text in the ayah uses the term Al-Zhaman) as it refers to the one whose thirst has intensified to the point that he imagines seeing the mirage and thinks of it as real water, so he follows and finds nothing upon reaching it; and realised that his dire need for it deceived him. Such are those whose deeds, because they were not in obedience of the Messenger, peace and blessings of Allah be upon him, and not for the sake of Allah, they were made like a mirage that was raised up away from them (when they reached it) despite their dire thirst, so they found nothing (of benefit from their deeds). On the contrary they found only Allah, Exalted is He (in wait for them) and He rewarded them the actual worth of their deeds and paid their actual dues (which amounted to nothing). It authentically narrated in the hadith of Abu Said al-Khudri from the Prophet, peace and blessings of Allah be upon him, wherein Allah shows Himself on the Day of Resurrection that Hellfire shall be brought in the appearance of a mirage, and it shall be said to the Jews “what did you used to worship?” to which they will say “we used to worship ‘Uzayr, the son of Allah” so it will be said to them “you have lied; Allah had neither a consort nor a son. So what is it that you want?” They shall answer “we want you to give us a drink.” It will be said to them “Drink” (from the mirage which will in reality will be Hellfire) and they shall fall into Hellfire. then it will be said to the Christians “what did you used to worship?” to which they will say “we used to worship the Messiah, the son of Allah” so it will be said to them “you have lied; Allah had neither a consort nor a son. So what is it that you want?’ They shall answer “we want you to give us a drink.”It will be said to them “Drink” and they too shall fall into the Hellfire – to the end of the hadith. (al-Bukhari 7001)
This is also the condition of every person who ascribes to falsehood, that his falsehood shall deceive him and let him down despite his great for it, and it is like its name indicates; void of benefit. Thus when a person adopts a belief contrary or variant to the truth, then the resultant deeds become nullified due to the falsity of their aim, just like a person who performs a deed done for other than Allah, Exalted is He, or not according to his Command. Furthermore, the doer of such deeds suffers nullification of his deeds as well as receiving the opposite of what he was hoping for.
Consequently, his work and deeds not only went in vain, but he also suffered punishment due to lack of any benefit from it; and from receiving the opposite of what he expected. This is why Allah, the Most High, says “finds Allah before Him, and He will pay him in full his due” – so this is the example of the misguided person who imagines himself to be on the path of guidance.
Paragons of the Qur’an by Ibn Qayyim al Jawziyyah Pages 34-37