Firstly, the Sunnah (recommended practice) in congregational prayer is to connect and align the rows. Connecting the rows means there should be no gaps between the worshipers, and there should be no empty space between the rows that would allow another row to be formed. This way, the rows will be one after the other.
Secondly, the jurists agreed that it is permissible to pray behind the imam if the men’s rows are in front and the women’s rows are behind them in the same hall, even if there is no barrier or partition between them.
They also agreed that it is permissible for the followers to pray behind the imam even if they are praying outside the prayer hall or outside the mosque, as long as the rows are connected and there is no significant gap between them.
They also agreed that it is permissible for a person to follow the imam in prayer even if they are in another room, as long as they can see or hear the imam, and there is no significant barrier such as a street or a river. If the mosque is crowded and people pray in the adjoining rooms of the mosque, their prayer behind the imam is valid as long as they can hear the imam or someone relaying his voice.
Thirdly, the prayer is valid for everyone even if the rows are not complete, and people are praying on multiple floors while there are empty spaces in the main prayer hall, even though this is khilaf al-awla (a view that contradicts the preferred or preferred opinion of the jurists in a particular matter).
Ibn Qudamah said in Al-Mughni: “Connecting the rows is not considered necessary if they are all in the mosque.”
Al-Aamidi said: “There is no disagreement in the [Hanbali] school of law that if a person is at the farthest end of the mosque and there is nothing preventing them from seeing or observing the imam, it is permissible to follow them in prayer, even if the rows are not connected.”
The only remaining disagreement is regarding praying alone behind the rows. The majority of the Hanafis, Malikis, and Shafi’is hold that it is permissible based on the hadith of Abu Bakrah and the validity of a woman’s prayer alone behind men.
The Hanbalis, on the other hand, hold that it is invalid based on the hadith that states, “There is no prayer for a person who prays alone behind the rows.” However, the majority of scholars responded by saying that the negation in this hadith is a negation of completeness, not of validity. Thus, the correct view is the opinion of the majority.
Fourthly, there is an important distinction in the issue of prayer in separate buildings:
If the separate buildings are within the same mosque, such as multiple floors, then the prayer behind the imam is valid if one of the following conditions is met:
The rows are connected in some way, the follower can see the imam or someone following the imam, or the follower can hear the imam or someone who stands in for him, provided that there is no significant barrier.
Therefore, it is permissible for the follower to pray behind the imam if they are in a separate building, as long as there is no significant barrier such as a street or a river.
However, if there is a significant barrier, the majority of scholars hold that following the imam is not valid, because if it were valid with a significant barrier, it would also be valid to follow the imam through a radio, and this would nullify the obligation of going to the mosque altogether.
Finally, there is no difference between men and women in the rules of aligning the rows and following the imam, except in the matter of arranging the rows if men and women are praying together.
And Allah knows best.
Fatwa by Dr. Khālid Naṣr