Answered by Shaykh Hamza Karamali, SunniPath Academy Teacher
My friend intended to perform Hajj this year, but died before the Hajj season. I would like to do Hajj on his behalf. Is this permissible? Do I need to gain the permission of his relatives before doing this?
[This answer was originally posted as a response to a student question in the course, The Reliance Explained — Part 2.]
In the Name of Allah, Most Merciful and Compassionate
A woman came to the Prophet (Allah bless him and give him peace) and said, “My mother vowed to perform a Hajj, but died before doing Hajj. Shall I now do Hajj on her behalf?” The Prophet (Allah bless him and give him peace) replied, “Yes, do Hajj on her behalf. Wouldn’t you settle a debt if your mother had died before being able to settle it? Pay Allah back, for Allah deserves more to be paid back.” (Bukhari)
Ibn Hajar al-Haytami noted that the Prophet (Allah bless him and give him peace) “likened Hajj to a debt and commanded that it be settled, which proves its obligation.”  In other words, just as it is obligatory to deduct debts from the deceased’s estate before estate division, it is also obligatory to deduct the cost of doing Hajj from the deceased’s estate and hire someone to do Hajj on the deceased’s behalf in order to pay back the debt that he / she owes to Allah Most High.
The Hajj on behalf of the deceased may also be performed voluntarily by anyone–whether a relative, a friend, or a complete stranger–just as a debt owed by the deceased may be settled by anyone.  You therefore don’t need the relatives’ permission in order to do this, but it would be good to inform them so that they know that the deceased’s debt of Hajj has been paid back.
And Allah Most High knows best.
 Ahmad Ibn Hajar al-Haytami, Tuhfat al-Muhtaj fi Sharh al-Minhaj, Kitab al-Hajj, Commentary on Nawawi’s words, al-naw` al-thani: istita`atu tahsilihi bi ghayrihi