Apparently, it invalidates the prayer, and it must be begun again. Yet I have some reservation about this, because if the worshipper has done what he was commanded to do, and the matter occurs without his choice and not through any negligence or heedlessness on his part, how can we invalidate his act of worship because of someone else’s action? The sinner here is the passer.
But if this happened through his own carelessness and lack of concern, as some people do, then there is no doubt that his prayer is invalidated.
His statement: “and counting the verses,” means that the worshipper is also permitted to count the verses. Verses is the plural of verse. A person may have need to count the verses, or he may not. One case in which he may need to count them is when he does not know al-Fatihah and wishes to recite from the Quran a passage containing the same number of verses. In that case, he needs to count them. Otherwise, he will generally have no need to count the verses. But if he needs to, he may do so; however, he should not count them verbally, because if he were to count them aloud, that would constitute speech, and speech invalidates the prayer. Rather, he should count them on his fingers or count them mentally. The prayer is not invalidated by mental activity, nor by physical movement, unless it is excessive and continuous without necessity.
He may also count the glorifications of Allah, and a person may need this, especially the imam. The jurists—may Allah have mercy on them—specified ten glorifications for the imam. They said: the maximum number of glorifications for the imam is ten, while the minimum for completeness is three. (1)
He may also count the units of prayer, and this may be more necessary than what preceded, because