All four schools of Islamic jurisprudence agree that it is permissible to perform Hajj on behalf of a deceased person who either had the obligation of Hajj but did not perform it, or as a voluntary act of devotion whose reward is gifted to the deceased. This ruling is based on several authentic hadith in which the Prophet Muhammad (peace be upon him) explicitly permitted proxy Hajj (hajj al-badal) for the deceased. The most well-known is the hadith of the woman from Juhaynah who asked about her mother who had vowed to perform Hajj but died before fulfilling it.
The conditions for performing proxy Hajj vary slightly across the schools, but the core requirements are agreed upon: the proxy (na'ib) should have already completed their own obligatory Hajj before performing it on someone else's behalf; the proxy should be a Muslim of sound mind; and the deceased should have been a Muslim. If the deceased had the financial and physical ability to perform Hajj during their lifetime but did not, the cost of sending someone for proxy Hajj should be taken from the deceased's estate before distributing the inheritance, according to the majority of scholars. This is treated like a debt owed to Allah.
The proxy should make the intention (niyyah) at the miqat specifically on behalf of the deceased, saying the talbiyah with the deceased's name: 'Labbayk on behalf of [name].' All the rites are performed exactly as one would for their own Hajj. The reward of the Hajj goes to the deceased, while the proxy also earns reward for their good deed. Scholars agree that the proxy may also perform Umrah on behalf of the deceased in the same manner.