Is the prayer invalidated when someone passes in front of a praying person?
Prayer of a praying person is not disrupted or invalidated by anyone passing in front of him/her. However, someone who passes between the body and the prostration place (where forehead touches) of a praying person has sinned because of disturbing the praying person.
There are several hadiths narrated by different chains of narrators about this:
Abu Juhaym said, “The Messenger of Allah (pbuh) said, ‘If the one who passes in front of a man praying knew what he was bringing upon himself it would be better for him to stop for forty than to pass in front of him.’ ” Abu’n-Nadr said, “I do not know whether he said forty days or months or years.” (Muwatta, Malik, Shortening the Prayer, Arabic Ref. Book 9, Hadith 366; Sunan Abi-Dawud, Prayer , Arabic Ref. 701)
It was narrated from ‘Abdur-Rahman bin Abu Sa’eed that his father said: “The Messenger of Allah (ﷺ) 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 devil (satan).’” (Sunan Ibn Majah, Establishing the Prayer and the Sunnah Regarding Them, Arabic Ref. Book 5, Hadith 1007)
A “sutrah = سترة” is an object that serves as a barrier or mark which should mark the reach of the forehead of a person where he/she prostrates during the prayer.
When the Prophet (pbuh) travelled, he would take with him a short piece of wood and pray facing it. In the open desert while going for a battle he would stab his spear in the ground and pray facing it. It is a confirmed Sunnah but it is not obligatory, because it is known that sometimes he also prayed without a sutrah.
The ruling differs while praying in congregation. Someone coming from behind and proceeding to fill a gap in a front row can pass in front of the praying people at the back rows without having committed a sin. Only passing in front of the imam, the person who leads the prayer, is forbidden.