Praise be to Allah.
If the prisoner is being held in a prison far away from the place where he lives, further than the distance at which shortening prayers becomes permissible, then he comes under the ruling on travellers.
If he does not know when he will get out of prison, he may shorten his prayers and put prayers together when there is a need to do so, until he gets out of prison or finds out that he will remain in prison for more than four days.
If he finds out that he will stay in prison for more than four days, such as one who is sentenced to imprisonment for longer than that, then the concessions of travel are not applicable in his case, according to the majority of fuqaha’.
The distance of travel for which the concessions of travel apply, according to the majority of fuqaha’, is approximately eighty kilometres. Whoever sets out to travel this distance or more may avail himself of the concessions of travel, such as wiping over the khuffayn (leather slippers or socks) for three days and nights, putting prayers together, shortening prayers, and breaking the fast of Ramadan.
If a traveller halts in a city but does not know when he will complete the purpose for which he travelled, and has not decided upon a specific length of time for his stay, he may avail himself of the concessions of travel even if he remains there for a long time.
Ibn Qudaamah (may Allah have mercy on him) said in al-Mughni (2/215):
If someone has not decided to stay longer than twenty-one prayers (i.e., more than four days), he may shorten his prayers, even if he stays for several years – such as if he stays to attend to some business in which he hopes he will succeed, or he stays to strive in jihad against an enemy, or the ruler detains him, or he is prevented from travelling by sickness – whether he thinks it most likely that he will fulfil the purpose for which he travelled within a short period or a lengthy period, provided that he thinks that completing his business will take a period of time that does not render the concessions on travel inapplicable.
Ibn al-Mundhir said: The scholars are agreed that the traveller may shorten his prayers so long as he has not decided to stay, even if that lasts for several years. End quote.
See also the answer to question no. 105844.
Those who are in prison are not obliged to offer Jumu‘ah prayer when they are in their dormitory. If they are able to offer this prayer in the mosque of the prison, then it is obligatory in that case.
The people in each dormitory should offer the five daily prayers in congregation in their dormitory, if they are not able to pray in the mosque of the prison.
Shaykh Ibn Baaz (may Allah have mercy on him) said:
The Council of Senior Scholars issued a fatwa stating that they do not agree with the idea that prisoners should all follow a single imam when praying Jumu‘ah or offering prayers in congregation when they are in their dormitories, following him in the prayer via a loudspeaker, because Jumu‘ah prayer is not obligatory for them, as they cannot go to attend the prayer, and for other reasons.
Whoever is able to attend the prison mosque for Jumu‘ah prayer – if there is a mosque in the prison in which Jumu‘ah prayer is offered – should offer this prayer with the congregation, otherwise it is waived in his case and he should pray Zuhr instead.
Each group should offer the five daily prayers in congregation in their dormitory, if it is not possible for them to gather in a mosque or in one place.
End quote from Majmoo‘ Fataawa Ibn Baaz (12/155-156).
The scholars of the Permanent Committee said:
If Jumu‘ah prayer is held in the prison or elsewhere, and the prisoner is able to offer Jumu‘ah prayer, then it is obligatory in his case. If he is not able to offer Jumu‘ah prayer, then he should pray Zuhr instead.
End quote from Fataawa al-Lajnah ad-Daa’imah (8/184).
If these people have been imprisoned because of sentences that have been passed against them, and they are staying in the prison to serve their sentences, then they come under the same rulings as people who are resident in a place, and they have no concession which would allow them to shorten the prayers or put prayers together, or to break the fast of Ramadan, but they may pray in congregation, each group praying in its own dormitory. They are not obliged to pray Jumu‘ah unless the prison administration gives them permission to pray in the prison mosque, in which case it becomes obligatory.
But if they are in a situation where they do not know where they will be tomorrow, and the administration of the prison usually moves them from one city to another, then in that situation they may avail themselves of the concessions of travel, and it is permissible for them to shorten prayers and put them together.
We ask Allah to bring about the release of those who have been imprisoned unjustly, and to relieve the distress of those Muslims who are facing hardship.
For more information, please see the answer to question no. 81421.
And Allah knows best.