If a person dies before performing obligatory Hajj or if one vowed to perform Hajj but died before fulfilling one’ s vow, his heir must assign someone to perform Hajj on behalf of the deceased. All the ensuing expenses in this regard must be paid out of the deceased’s property, as indeed must be any debts left by him.
Ibn ‘Abbas narrates that a woman from the tribe of Johainah came to the Prophet (peace be upon him) and said: “My mother had vowed to perform Hajj but she died before fulfilling her vow, should I perform Hajj on her behalf? The Prophet (peace be upon him) said: “Yes, perform Hajj on her behalf. Would you not pay off any debts your mother might have left behind upon her death? Pay off what you owe to Allah, for He is most deserving of settlement of His debt.” (Bukhari)
This hadith underlines the obligation of performing Hajj on behalf of a deceased person, whether or not he leaves a will to this effect (it is a kind of debt for the deceased), and all debts left by the deceased must be settled, just as all other financial obligations such as zakah, an atonement or a vow transacted by the deceased has to be fulfilled.
Ibn ‘Abbas, Zaid bin Thabit, Abu Hurairah, and Ash-Shafi’i hold this opinion. They consider that the expenses of the substitute (the hired person) must be paid out of the wealth of the deceased before dividing it up among his heirs.
In case the wealth is insufficient to cover both the cost of Hajj (by the substitute) and settlement of the deceased’s debts, the expense of Hajj must be paid first, as the Prophet (peace be upon him) said: “Allah is most deserving that His debt be paid back.”
Imam Malik says: “A person may perform Hajj on behalf of the deceased only if the deceased leaves a will to that effect. If the deceased leaves no such will, then a Hajj on his behalf may not be performed, for this worship involves, more than anything else, physical exertion and struggle and as such, no other person can replace or substitute another person. If a deceased makes a will regarding it, then Hajj may be performed, meeting all its cost from out of one third of the share of his heritage.”