Accordingly, verses such as Allah’s statement, “But those who disbelieve—their deeds are like a mirage …” (Q 24:39) are to be understood as referring to the person who dies in a state of disbelief. On the face of it there is no evidence to the contrary, and Allah’s bounty is far broader than this, so the point should not be regarded as improbable. As for the ḥadīth, “Faith wipes out whatever preceded it,” that applies to sins and misdeeds, not to righteous acts.
I say: The same applies to the verse cited by al-Sindī—indeed, to every verse that speaks of deeds being annulled by associationism—such as Allah’s words, “It has already been revealed to you and to those before you that, if you associate partners with Him, your deeds will surely be nullified and you will certainly be among the losers” (Q 39:65). All of these verses concern the one who dies as a polytheist. A supporting proof is Allah’s saying, “Whoever among you turns back from his religion and dies as a disbeliever—their deeds will have been rendered void in this world and the Hereafter, and they will be the companions of the Fire, abiding therein forever” (Q 2:217).
A juristic corollary arises from this: if a Muslim performs ḥajj, then apostatises, and thereafter returns to Islam, his ḥajj is not invalidated and he is not obliged to repeat it. This is the position of Imām al-Shāfiʿī and one of the two reported opinions of al-Layth ibn Saʿd; it was also adopted by Ibn Ḥazm, who championed it with a strong and cogent argument that, in my view, must be quoted. He, may Allah have mercy on him, said (7 / 277):
“Issue: One who has performed ḥajj and ʿumrah, then apostasises, and whom Allah subsequently guides and delivers from the Fire so that he re-enters Islam, is not required to repeat either ḥajj or ʿumrah. This is the view of al-Shāfiʿī and one of the two positions reported from al-Layth. Abū Ḥanīfah, Mālik and Abū Sulaymān maintained that he must repeat both ḥajj and ʿumrah, adducing as evidence Allah’s statement, ‘If you associate partners with Him, your deeds will surely be nullified and you will certainly be among the losers’ (Q 39:65). We know of no other proof for them.”