Assalamualaikum ustaz. Some people will pray right at the mosque’s entrance when it is actually a place where people will go in and out. What is the ruling of passing in front of a person praying there?
Waalaikumussalam wrt. wbt.,
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions, and all those who follow his footsteps until the Final day.
Before answering the above question, we’d like to first explain the rulings related to sutrah when praying. Sutrah lexically means anything that acts as a barrier.  Sutrah is a terminology used in fiqh to mean anything that is upright in front of a person praying. It can be a sane, arranged soil or other similar things to prevent others from passing in front of him. 
In a hadith narrated from Abu Sa’id al-Khudri RA, Rasullullah PBUH said:
إِذَا صَلَّى أَحَدُكُمْ فَلْيُصَلِّ إِلَى سُتْرَةٍ ، وَلْيَدْنُ مِنْهَا ، وَلَا يَدَعْ أَحَدًا يَمُرُّ بَيْنَ يَدَيْهِ ، فَإِنْ جَاءَ أَحَدٌ يَمُرُّ ، فَلْيُقَاتِلْهُ ، فَإِنَّهُ شَيْطَانٌ
“When anyone of you performs prayer, let him pray facing towards a Sutrah, and let him get close to it, and not let anyone pass in front of him. If someone comes and wants to pass in front of him, let him fight him, for he is a Syaitan (Satan).” 
It is stated in the book al-Fiqh al-Manhaji (1/392-393): Among the sunnah of prayer is to make something as a barrier (سترَةٌ) in front of him. It is as a separator between the person praying and people who are walking in front of him, such as a wall, pillar, cane, or laying a praying mat and others. If none could be found, then just make or draw a line. This is based on a hadith from Ibn Umar RA, he said:
أَنَّ رَسُولَ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ كَانَ إِذَا خَرَجَ يَوْمَ الْعِيدِ أَمَرَ بِالْحَرْبَةِ فَتُوضَعُ بَيْنَ يَدَيْهِ، فَيُصَلِّى إِلَيْهَا وَالنَّاسُ وَرَاءَهُ، وَكَانَ يَفْعَلُ ذَلِكَ فِى السَّفَرِ
“When the Messenger of Allah (ﷺ) would go out (for prayer) on the day of ‘Id, he ordered to bring a lance, it was then setup in front of him and he would pray in its direction, and the people (stood) behind him.” 
In a hadith narrated from Abu Hurairah RA, Rasullullah PBUH said:
إِذَا صَلَّى أَحَدُكُمْ فَلْيَجْعَلْ تِلْقَاءَ وَجْهِهِ شَيْئًا فَإِنْ لَمْ يَجِدْ فَلْيَنْصِبْ عَصًا فَإِنْ لَمْ يَكُنْ مَعَهُ عَصًا فَلْيَخْطُطْ خَطًّا ثُمَّ لاَ يَضُرُّهُ مَا مَرَّ أَمَامَهُ
“When one of you prays, he should put something in front of his face, and if he can find nothing, he should set up his staff; but if he has no staff, he should draw a line; then what passes in front of him will not harm him.” 
In the book al-Mausu’ah al-Fiqhiyyah al-Kuwaitiyyah, it is stated: Hanafiyah and Syafi’iyyah scholars analogically deduced a line with the place of prayer such as a praying mat. Al-Tahtawi said: This is prioritized analogical deduction because al-mushalla (a place one stands in prayer; a praying mat) would be effective in preventing others from passing in front of him compared to just a line.
Thus, Syafi’iyyah scholars prioritize a praying mat over just a line. They stated: “(Praying mat) is prioritized compared to a line for it is in line with the meaning (of sutrah).” 
Imam al-Nawawi stated: “It is sunnah for those who pray to make a sutrah in front of him such as a wall, pillar and pray close to it, with the distance between the two is not more than three hasta. If a person prays in a desert, he should place his staff or something similar upright in front of him or gather some things from his mount or adornments that it becomes the size of a horse saddle.
If he couldn’t find anything to make a sutrah, then draw a line in front of him or lay a throw as the place of prayer. Imam al-Haramain and al-Ghazali said, there is no ibrah by drawing a line (it means it is impermissible). However, the truth is what has been set by the jumhur, it is sufficient with a line just like if he has something in front of him.” 
Thus, according to the above evidences, the statement of Rasullullah PBUH “فَإِنْ لَمْ يَكُنْ مَعَهُ عَصًا فَلْيَخْطُطْ خَطًّا ثُمَّ لاَ يَضُرُّهُ مَا مَرَّ أَمَامَهُ” clearly shows, first, one should use a cane or anything that can be placed upright in front of him. However, if there is nothing, it is sufficient to draw a line as the separator of sutrah in prayer.
Coming back to the above question, as we know, passing in front of a person praying is impermissible and prohibited according to sahih and sarih evidences. This is if there is no sutrah or barrier.
Rasullullah PBUH said:
لَوْ يَعْلَمُ الْمَارُّ بَيْنَ يَدَيِ الْمُصَلِّي مَاذَا عَلَيْهِ، لَكَانَ أَنْ يَقِفَ أَرْبَعِينَ خَيْرًا لَهُ مِنْ أَنْ يَمُرَّ بَيْنَ يَدَيْهِ
“If the one who passes in front of a person who is praying knew what (burden of sin) there is on him, standing for forty would be better for him than passing in front of him.” 
According to this hadith, it is prohibited to pass in front of a person praying. The wisdom of this prohibition is because a person praying is supplicating and speaking to Allah SWT. Thus, a person passing in front of a person praying means that he has severed the supplication and makes the person praying loses focus. 
Abu Nasr said:
لَا أَدْرِي، أَقَالَ أَرْبَعِينَ يَوْمًا، أَوْ شَهْرًا، أَوْ سَنَةً
“I do not know whether he said forty days or months or years.”
Whilst in the narration of al-Bazzar it is stated with 40 fall season or with the meaning of 40 years.
This hadith shows that it is prohibited to pass in from of a person praying if he placed a barrier or sutrah, however, it is the opposite if he didn’t use it, then it isn’t included in the narration of Ibn Hibban in his sahih from al-Muttalib bin Abi Wada’ah RA, who said: “I saw the Prophet PBUH, after his tawaf, walk through the place of tawaf and then prayed two rakaat when there is no screen or anything between him and the people who are doing tawaf.” 
Thus, a person praying must prevent others from passing in front of him by holding the other person back. However, in reality, such as the situation in the question, then it is suggested for those who are praying to move a little farther than the entrance so that he is not obstructing other congregants who have prayed to exit the mosque, especially if there is a lot of congregants. When he is stepping away, he should move in a manner of a person praying and not like he isn’t praying.
In our opinion, an understanding and acceptance between congregants are crucial in maintaining a harmonious environment among Muslims. Likewise, fiqh understanding and knowledge are of utmost importance for both the imam and makmum. This is so that the implementation of prayer can be fulfilled with khusyuk, harmony and understanding the true situation.
Choose a place of prayer where there is a wall or pillar in the mosque to avoid other congregants from passing in front of you. It is narrated that the Prophet PBUH once prayed while facing a pillar in a mosque, a tree and others.
We end this discussion with a hadith from Abi Hurairah RA from the Prophet PBUH:
إِذَا صَلَّى أَحَدُكُمْ فَلْيَجْعَلْ تِلْقَاءَ وَجْهِهِ شَيْئًا، فَإِنْ لَمْ يَجِدْ فَلْيُلْقِ عَصًا، فَإِنْ لَمْ يَجِدْ عَصًا فَلْيَخُطَّ خَطًّا، ثُمَّ لَا يَضُرُّهُ مَا يَمُرُّ بَيْنَ يَدَيْهِ
“When anyone of you performs prayer, let him put something in front of him. If he cannot find anything then let him put a stick. If he cannot find one, then let him draw a line. Then it will not matter if anything passes in front of him.” 
According to madhhab Hanafi and Maliki, placing sutrah or screen is sunnah for those who are concerned that someone will walk past in front of them. This is strengthened with a hadith of Ibn Abbas who narrated that the Prophet PBUH prayed in open land and there is nothing (no sutrah) in front of him, just like in the narration of Abu Daud.
May we be blessed with a true understanding in religion so that our worships are accepted by Allah SWT.
 See al-Qamus al-Muhith
 See al-Mausu’ah al-Fiqhiyyah al-Kuwaitiyyah, 3/176-177
 Narrated by Ibn Majah (1007)
 Narrated by al-Bukhari (472) and Muslim (501)
 Narrated by Abu Daud (689). Imam al-Nawawi stated that al-Baghawi and other hadith scholars said that this hadith is weak.
 See al-Mausu’ah al-Fiqhiyyah al-Kuwaitiyyah, 24/180; Also see Hasyiyah al-Tahtawi ‘ala Maraqi al-Falah, hlm. 101 dan Mughni al-Muhtaj, 1/200
 See Raudhah al-Thalibin, 1/108
 Narrated by al-Bukhari (510) and Muslim (507)
 See Minhah al-‘Allam fi Syarh Bulugh al-Maram, 2/397
 See Mawarid al-Zam’an, pg. 118
 Narrated by Abu Daud (689) and Ibn Majah (943)