The Effects of Tawheed at the time of death-Imaam Ibnul Qayyim
In The Name of Allaah, The Most Merciful, The Bestower of Mercy
Imaam Ibnul Qayyim (rahimahullaah) stated:
The Shahaadah [i.e. to testify that ‘None has the right to be worshipped except Allaah] when (uttered) at the time of death wipes away one’s evil deeds. That is because the one who utters it at the time of departure from this world does so with certainty and knowledge of its true meaning. All his (or her) desires (for the worldly life) come to an end and his (or her) rebellious soul (becomes) mild and submissive after being in (a state of) refusal and disobedience; a (state of) approval after turning away, and a state of humility after being held in high esteem. The (heart’s and the soul’s) eagerness for the worldly life and its merits departs- distanced (from everything) whilst in the presence of its Lord, Originator and true Protector; humble in the presence of its Lord, hopeful of Pardon, Forgiveness and Mercy.
Belief in the Oneness of Allaah -[i.e. the belief in the Oneness of Allaah’s Lordship (that Allaah alone is the creator, sustainer and the one in control of all the affairs of the universe); and that Allaah alone has perfect Names and Attributes and that none is similar to Allaah; and that Allaah alone has the right to be worshipped]-frees and distances the soul from that which leads to Shirk [polytheism] and manifests the reality of its falsity. Therefore, those wishes which the soul busied itself with [in the worldly life] ceases [at the time of departure from this world] and all its concern is [directed towards] The One it is certain to meet [i.e. Allaah].
The person [who is blessed with the ability to utter this testimony of faith] focuses his (or her) attention completely on Allaah- turns to Allaah with his (or her) soul and desire, and submits to Allaah alone – inwardly and outwardly. The person’s hidden affair [i.e. the heart and soul] and outward affair [i.e. what he (or she) proclaims] testify to the same thing, so he (or she) sincerely says: “None has the right to be worshipped except Allaah.” His (or her) heart is freed from attachment to other than Allaah -all the worldly (desires) leaves the heart because he (or she) is about to stand in Allaah’s presence. The intensity of his (or her) desire [for the worldly life] is extinguished and the heart is filled with the [desire for] the afterlife, and thus it becomes the attention of the person’s eyes and the worldly life is forgotten. [When] this sincere testimony is his (or her) last deed, it purifies him (or her) from sins and thus Allaah enters [him or her into a noble position]. That is because he (or she) meets Allaah with a truthful and pure testimony, whose outward manifestation is in agreement with [what is hidden in the heart and soul].
If a person made this (type) of testimony during the time of well-being [whilst residing in the worldly life], he (or she) would not have placed great importance on worldly desires, rather he would have attached himself (or herself) to Allaah alone; but [the fact of the matter is that] he (or she) made this testimony [in the worldly life] with a heart filled with desires, love of life and its means of subsistence.
[Source: Al-Fawaa-id. Page: 91-92. Abridged and slightly paraphrased]