Once it was clear to him that the man really did intend to leave the mosque, he said, “As for this one, he has disobeyed Abū al-Qāsim,” meaning the Messenger of Allah ﷺ. When a Companion says, “He has disobeyed Abū al-Qāsim,” the statement carries the force of being traced back to the Prophet himself—-as though he were saying, “The Messenger of Allah ﷺ forbade this.”
On the basis of this ḥadith the scholars have concluded that it is unlawful for anyone upon whom the prayer is obligatory to exit the mosque after the adhān unless he has a valid excuse. Examples of such excuses include:
• being pressed to urinate,
• needing to relieve oneself,
• having trapped wind that requires breaking one’s ablution,
• being afflicted by an illness that necessitates leaving,
• being the imam of another mosque, or
• being the muʾadhdhin of another mosque.
As for leaving this mosque in order to pray in another one, the ruling is a matter of hesitation. One person might argue that the ḥadith is general, while another could say that it concerns only someone who leaves so as not to pray with any congregation at all. If a person departs one mosque merely to pray in another, he has not abandoned congregational prayer; he has simply chosen a different congregation. Even so, one should not leave—-even with the intention of praying elsewhere—-unless a legitimate sharʿī reason exists, such as wanting to perform the funeral prayer being held in the other mosque, or because the recitation there is finer, or some similar lawful motive. In such cases we say there is no harm in leaving. And Allah is the One who grants success.