Short answer
No, it is a sin to pass directly in front of someone praying, within the area of his sajdah or, in a small room, anywhere between him and the wall. The person praying should place a sutrah (a barrier) in front of him where people may pass, and you may then walk beyond it. The passing does not break his prayer.
Passing in front of a person praying, inside the place of his prostration in a large space, or anywhere before him in a small masjid or room, is makruh tahrimi and sinful. A sutrah at least about a forearm high is sunnah for the imam and for someone praying alone where people may pass; the imam's sutrah covers the followers. Passing does not invalidate the prayer.
Other madhhabs
- Hanbali
- The same, except that a black dog passing in front of the one praying invalidates the prayer.
Explanation
The Prophet ﷺ said that if the one passing in front of a person praying knew what sin he carried, standing for forty would be better for him than passing in front. The narrator was unsure whether he said forty days, months or years. He also told the person praying to pray towards a sutrah and stand close to it.
What counts as "in front":
- Large masjid or open space: the area up to where his sajdah reaches, or roughly as far as his gaze falls when he looks at the place of sajdah. Beyond that you may pass.
- Small masjid, room or house: anywhere between him and the wall in front, unless there is a sutrah.
- With a sutrah: pass beyond it, not between him and it.
- In congregation: the imam's sutrah covers everyone, so walking in front of the rows of followers to fill a gap or leave is less serious, though still best avoided.
For the one praying: do not pray in a doorway or walkway where people must pass, or the blame shifts onto you. Put something in front of you: a chair, a bag, a pillar or a wall, at least about a forearm high. If someone tries to pass close in front, you may gently signal with your hand, but do not move much.
In Makkah: many scholars excuse passing in front of people in the Masjid al-Haram during crowding, since it cannot be avoided. See also the sunnah acts of salah and what is not allowed in the masjid.
The evidence
Sahih al-Bukhari 510
Sahih... لو يعلم المار بين يدي المصلي ماذا عليه ...
"If the one passing in front of a person praying knew what he carries, it would be better for him to stand for forty than to pass in front of him."
Passing in front of someone praying is a serious sin.
Sunan Abi Dawud 698
Grading to be checked... إذا صلى أحدكم فليصل إلى سترة وليدن منها ...
"When one of you prays, let him pray towards a sutrah and come close to it."
The sutrah is the sunnah protection for the person praying.
Where the ruling is recorded
- al-Hidaya, Kitab al-Salah, chapter on what invalidates the prayer and what is disliked in it. Passing in front of one praying does not invalidate the prayer; the passer sins; a sutrah of about a cubit is sunnah.
- Radd al-Muhtar (Ibn Abidin), Kitab al-Salah, chapter on what is disliked in the prayer. The extent of the forbidden area in large and small masjids, and the imam's sutrah sufficing for the followers.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.