Ruling on Praying Alone Behind the Row
Question

If a worshipper enters the mosque and finds the congregation praying, and there is no space in the row, should he pray standing alone behind them, or get one of the worshippers in the row in front of him to stand beside him?
Praise be to Allah.Praying alone behind the row
We have stated in the answer to question no. 1947  that it is not acceptable to pray standing on one's own behind the row. This is the well-known view of Imam Ahmad (may Allah have mercy on him), and is the view favoured by more than one of the scholars. 
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) was asked about this matter and he gave a detailed answer in which he said: 
Discussion of this matter covers two topics: 

Is the prayer of one who prays on his own behind the row valid or not? 
 If we say that it is not valid, and he finds the row full , what should he do? 


With regard to the first topic, the scholars (may Allah have mercy on them) differed concerning it. 

Some of them said that the prayer of one who prays on his own behind the row is valid, whether he has an excuse or not, but some of them stated that this is makrooh if one does not have an excuse. This is the view of the three Imams, Malik, Ash-Shafa’i and Abu Hanifah (may Allah have mercy on them). 
They quoted as evidence the fact that the prayer of a woman who prays behind the row is valid, and they said that men and women are equal with regard to Islamic rulings. And the Prophet (peace and blessings of Allah be upon him) did not tell Abu Bakrah (may Allah be pleased with him), when he bowed before joining the row, to repeat his prayer. [The Hadith of Abu Bakrah was narrated by Al-Bukhari, 783.) 
And the Prophet (peace and blessings of Allah be upon him) brought Ibn 'Abbas from behind to stand beside him during the prayer [Narrated by Al-Bukhari, 117 and Muslim, 763]. If it permissible for a person to stand alone during part of the prayer, then it should be permissible for him to do so during the whole of the prayer, because if that invalidates the prayer it should make no difference whether it is done to a lesser extent or a greater, like standing in front of the Imam.  
They responded to the Hadiths which forbid praying standing alone behind the row by saying that what is meant is that prayer done in such a manner is lacking (but not invalid). This is like the Hadith in which the Prophet (peace and blessings of Allah be upon him) says, “There is no prayer when food is ready” [Muslim, 650], and so on. 
Some of the scholars said that the prayer of one who prays on his own behind the row is not valid. This is the view of Imam Ahmad that is well known among his companions. There is another report from him in which he agrees with the other three Imams. 
Those who favour this view based it on reports and rational thinking: 

The report is that which was narrated by Imam Ahmad (15862) from ‘Ali ibn Shayban (may Allah be pleased with him), that the Prophet (peace and blessings of Allah be upon him) saw a man praying behind the row and when he finished he said to him: “Repeat your prayer, for there is no prayer for the one who prays on his own behind the row.” This is a sound Hadith for which there are corroborating reports which suggest that it is authentic. 
As for rational thinking, the jama’ah (congregation ) is a coming together, in which people are in the same place, doing the same actions. So the people who are gathered act in unison, following the Imam , and they are gathered in the same place, namely the rows . If we say that it is permissible for them to be separate from one another, how can they be a unified gathering? 

These scholars responded to the evidence quoted by those who say that it is permissible for a woman to stand on her own behind the row of men by saying that the Sunnah indicates that this is a ruling which applies only to women, as in the Hadith of Anas (may Allah be pleased with him) who said: “The orphan and I stood behind him – meaning behind the Prophet (peace and blessings of Allah be upon him) – and the old woman stood behind us,” [Narrated by Al-Bukhari, 234; Muslim, 658], because it was not appropriate for her to stand beside the men. 
With regard to the Hadith of Abu Bakrah, he did not stand on his own except for a short while and the Prophet (peace and blessings of Allah be upon him) said to him: “Don’t do it again.” 
With regard to the Hadith of Ibn 'Abbas (may Allah be pleased with him) he did not stand behind the row, rather he was passing by and not standing and praying. 
With regard to their view that what is meant by the Hadith which says there is no prayer for one who stands behind the row is that his prayer is lacking but is still valid, this interpretation is to be rejected because the basic principle concerning negation in Arabic is that it is usually to be understand as meaning that the thing referred to does not exist; if it is not possible to interpret it in this manner, then it is to be understood as meaning that it is not valid; only if it cannot be interpreted in this manner may it be understood as meaning that it is lacking or imperfect.  The Hadith in question may be understood as meaning that such a prayer is invalid, so it should be interpreted in that manner. 
With regard to their quoting the Hadith, “There is no prayer when food is ready,” their interpretation is not valid on two counts: 

The reason for this is that the mind may be distracted because of the food being ready. Distraction of the mind does not mean that the prayer is invalidated, as is clear from the Hadith about waswasah (whispers from the devil) in which it says that satan comes to the worshipper and says, “Remember such and such, remember such and such,” that he had not remembered, and he carries on until (the worshipper) does not know how many rak’ahs he has prayed. [Narrated by Al-Bukhari, 608; Muslim, 389].
The Hadith, “There is no prayer for the one who stands on his own behind the row” clearly indicates that the prayer is not valid, because the Prophet (peace and blessings of Allah be upon him) told him to repeat his prayer and stated that reason for that was that there is no prayer for the one who stands on his own behind the row.

In the Hadith of Wabisah (may Allah be pleased with him) it is stated that the Prophet (peace and blessings of Allah be upon him) saw a man praying on his own behind the row, and he told him to repeat his prayer. [Narrated by Abu Dawood, 682; At-Tirmidhi, 230] 
Thus it is clear that the most correct view is that standing in the row is obligatory and that the prayer of one who prays on his own behind the row is invalid, and he must repeat his prayer because he has omitted the duty of standing in the row. 
But this duty, like others, is waived if there is no room in the row, or if a person is unable to do it because of a legitimate Shar’i excuse, or he is physically unable to do it, because Allah says (interpretation of the meaning): 
“So keep your duty to Allah and fear Him as much as you can.” [At-Taghabun 64:16]
And the Prophet (peace and blessings of Allah be upon him) said: “When I command you to do something, do as much of it as you can.”  [Narrated by Al-Bukhari, 7288; Muslim, 1227]  So he should stand in the row wherever he finds a space. If he cannot find a space then this obligation is waived in this case. It is also waived if a person cannot stand in the row for a Shar’i reason. 

An example of the first scenario is: If he finds the row is full, then he can pray standing on his own, because there is no obligation if one is unable to fulfil it. 
An example of the second scenario is: If a woman is on her own with a group of men, she should pray standing on her own behind the row, as is proven in the Sunnah. What is taught in the Sunnah can be taken as a basis for analogy for saying that a man may pray on his own behind the row if he cannot find any space in the row, because a physical excuse is like a Shar’i excuse.  

Explanation: If a man comes and finds the row is full, then he may either move forward and stand beside the Imam, or he can pull someone out of the row to stand beside him, or he can pray on his own, apart from the congregation, or he can pray with the congregation behind the row. 
Moving forward and standing beside the Imam
With regard to moving forward and standing beside the Imam: 

This is going against the Sunnah which is for the Imam to stand on his own, distinct from the congregation by standing in front of them and doing the actions of the prayer before them. This is not refuted by the fact that the Prophet (peace and blessings of Allah be upon him) stood beside Abu Bakr (may Allah be pleased with him) [as narrated by Muslim, 412], because in this case the one who came and stood is the Imam who came and stood beside his deputy. Moreover, Abu Bakr could not go back and stand in the row, and it was in the interests of the congregation for him to stand beside the Prophet (peace and blessings of Allah be upon him) and relay his Takbirs.
For a person who finds the row full to come and stand beside the Imam causes annoyance to the congregation in order for him to reach the Imam.
It also denies those who come after him the opportunity to stand in a row; if he stands on his own and someone else comes along they will form a row.

Pulling someone out of the row to stand beside you
With regard to pulling someone out of the row to stand beside him, this includes three wrongful actions: 

It creates a gap in the row, and the Prophet (peace and blessings of Allah be upon him) commanded us to form compact rows and forbade us to leave gaps for the devil. [Ahmad, 5691; Abu Dawood, 666; classed as authentic by Al-Albani in As-Sahihah.
It wrongs the person who is pulled out, by moving him from a better spot to a worse spot.
It distracts him from his prayer and he may argue with him and criticise him when he has finished praying.

This is not altered by the report which states that the Prophet (peace and blessings of Allah be upon him) said to a person whom he saw praying on his own behind the row: “Why did you not join the row or pull someone out?” because this is a weak Hadith which cannot be used as evidence. [Narrated by At-Tabarani in Al-Awsat, 8/374. Al-Haythami said: (it is) very inauthentic]. 
As for leaving the congregation and praying on his own, this is omitting an obligatory duty when one is able to do it, so it is a sin. 
Praying with the congregation behind the row is doing one’s duty to the best of one's ability. The one who prays with the congregation must do two things: 

Pray in congregation
Stand in the row with them.

If he is unable to do one of them then he must do the other. 
If it is said that the words of the Prophet (peace and blessings of Allah be upon him), “There is no prayer for one who stands alone behind the row” are general in meaning and it makes no difference whether the row is full or not, the answer is that this indicates that the prayer of one who stands alone is invalid because he has omitted the obligation of standing in a row. But if he is not able to do it then this obligation is waived. The Prophet (peace and blessings of Allah be upon him) could not have declared a person’s prayer to be invalid for not doing something that he was not able to do. 
Similar examples are to be found in the Hadiths in which the Prophet (peace and blessings of Allah be upon him) said: “There is no prayer for the one who does not recite the Essence of the Quran (i.e., Surat Al-Fatihah)” [Narrated by Al-Bukhari, 756; Muslim, 394] and “There is no prayer for the one who does not have Wudu” [Narrated by Imam Ahmad, 9137; Abu Dawud, 101; Ibn Majah, 399] – if the latter is authentic. For the one who is unable to recite Al-Fatihah or to do Wudu should pray without them, and his prayer will be sufficient. But he should recite a passage of Quran that is equivalent in length to Al-Fatihah, or he should remember Allah (say Dhikr) if he is unable to recite any Quran, and he should do Tayammum if he is unable to do Wudu’. 
In conclusion, standing in the row is obligatory. If a person comes and the row is full, he should pray with the congregation behind the row, and not go forward to stand beside the Imam or pull someone out to stand beside him, nor should he abandon the prayer in congregation . 
The view that it is permissible to pray in congregation standing alone behind the row if one has an excuse for doing so is the view favoured by Shaykh Al-Islam Ibn Taymiyah and Shaykh ‘Abd Al-Rahman Al-Sa’di (may Allah have mercy on them both), and there are some who say it is valid in all cases. 
And all praises belong to the Lord of the Worlds.
And Allah knows best.