It is not permissible to perform Hajj on behalf of a prisoner even if he is sentenced to life imprisonment, and it is not correct to give the prisoner the same ruling of the deceased or the sick person who is not expecting a recovery. In addition, Hajj is not an obligation on the prisoner since he is not able to perform it. Moreover, the prisoner always has a chance to be set free regardless of how long he is being imprisoned.

Elaborating more on this issue, Dr. Husam Al-Din ibn Musa `Afana, professor of Usul Al-Fiqh, states,

The majority of scholars agree that it is permissible to perform Hajj on behalf of others in the following two cases:

First, performing Hajj on behalf of a deceased person: It has been narrated by Ibn `Abbas that a woman asked Prophet Muhammad (peace and blessing be upon him) if she should perform Hajj on behalf of her mother who had vowed to perform Hajj for the sake of Allah but died before fulfilling that vow. He said, “Perform Hajj on her behalf. If she had a debt, you would have paid for her, wouldn’t you?” She said, “Yes.” He said, “So pay it. For Allah has more right to be paid” (Al-Bukhari).

It is also narrated by Ibn `Abbas that a man asked the Prophet, “O Messenger of Allah, my father died and he has not performed Hajj. Can I perform Hajj on his behalf?” The Prophet replied, “Yes, for the debt of Allah has more right to be paid” (An-Nasa’i).

Furthermore, Imam Abu Ishaq Al-Shirazi says in Al-Muhadhabb, “Since Hajj is a duty that can be performed by proxy during one’s lifetime, its like human debts that does not get cancelled out by death. Thus, it must be performed on his [the deceased’s] behalf from the miqat, and its expenses should be taken from the money he left, because it is an obligatory duty. Therefore, its costs should be taken from his money just like people’s debts.”

Second , performing Hajj on behalf of a sick person who is not expecting recovery or a person who is not able to handle the difficulties of the journey: It is narrated by Ibn `Abbas that Al-Fadlibn `Abbas was riding [the mount] with the Prophet when a woman came to the Prophet and said, “O Messenger of Allah, the command of Allah to His slaves to perform Hajj has come when my father is an old man who cannot sit firmly in the saddle. Can I perform Hajj on his behalf?” He said, “Yes;” and this was during the Prophet’s farewell pilgrimage (Al-Bukhari and Muslim).

It is also narrated by Abu Ruzayn Al-`Uqayli (may Allah be pleased with him) that he said, “O Messenger of Allah, my father is an old man and he cannot perform Hajj and `Umrah and cannot travel, can I perform Hajj on his behalf?” The Prophet said, “Perform Hajj and `Umrah on behalf of your father” (An-Nasa’i).

Additionally, it is narrated by `Abdullah ibn Al-Zubayr that a man came to the Prophet and said, “My father is an old man who cannot travel, and the command of Allah to perform Hajj has come. Can I perform Hajj on his behalf?” The Prophet replied, “Are you his eldest son?” The man said, “Yes.” The Prophet asked, “If your father had a debt, would you have paid it for him?” The man said, “Yes.” The Prophet said, “Then perform Hajj on his behalf” (Ahmad and An-Nasa’i).

Based on the above, the majority of the scholars have agreed that it is permissible to perform Hajj on behalf of the deceased and the sick person who are not expecting to recover and also on behalf of the elderly who cannot bear the burdens of the journey. A person who performs Hajj on behalf of those people should have performed Hajj for himself or herself first. This is the opinion of the Shafi`is, Hanbalis, Al-Awza`i, and IshaqibnRahawayh, as stated by Imam IbnQudamah in Al-Mughni.

This condition is based on the hadith in which Ibn `Abbas narrates that the Prophet heard a man saying “O Allah! Here I am in response to Your call on behalf of Shubrumah.” The Prophet asked him, “Have you performed your own Hajj?” He replied, “No,” whereupon the Prophet told him, “You must perform Hajj for yourself first, and then for Shubrumah(Abu Dawud and IbnMajah).

In conclusion, it is clear that it is not permissible to perform Hajj on behalf of others than the deceased and the sick person who are not expecting to recover and the elderly who cannot bear the burdens of the journey. Thus, it is not permissible to perform Hajj on behalf of a prisoner, even if he or she is sentenced to life imprisonment. It is not correct to give the prisoner the same ruling of a deceased or sick person. Additionally, the prisoner is not able to perform Hajj, therefore it is not a must on him or her.

Allah does not impose upon us a duty but to the extent of our ability, He Almighty says, (Pilgrimage thereto is a duty people owe to Allah, – those who can afford the journey) (aal `Imran 3:97), and He Almighty also says, (Allah does not impose upon any soul a duty but to the extent of its ability) (Al-Baqarah 2:286).

Finally, the prisoner — regardless of how long he or she has been imprisoned — always has a chance to be set free.