as Ibn Ḥazm stated explicitly, and what has already been mentioned is therefore another proof that it is unlawful for such people to enter the mosque, for prohibition is the counterpart of the obligation to expel them.
Excepted from this are those who have eaten it out of necessity, such as severe hunger or for medical treatment; such a person may enter and is not to be removed. This is based on the ḥadith of al-Mughīrah ibn Shuʿbah, who said:
“I ate garlic and went to the prayer-place of the Prophet ﷺ, having already missed one rakʿah. When I entered the mosque, the Prophet ﷺ noticed the smell of garlic. After the Messenger of Allah ﷺ completed the prayer he said, ‘Whoever has eaten from this plant must not come near us until its odor—or his odor—has gone.’ When I had finished the prayer, I approached the Messenger of Allah ﷺ and said, ‘Messenger of Allah, would you offer me your hand?’ He then put his hand inside the sleeve of my shirt until it reached my chest, where he felt a bandage across it, and said, ‘You have an excuse.’”
Abū Dāwūd recorded this report with a sound chain, as noted earlier in the documentation of the chapter’s ḥadiths, and al-Bayhaqī also included it in his Sunan al-Kubrā.
As for the narration that al-Bukhārī cited in suspended form—“The Prophet ﷺ said: ‘Whoever eats garlic or onion, whether because of hunger or for some other reason, must not approach our mosque’”—Ibn Ḥajar remarked: “I have not found the qualification ‘because of hunger or otherwise’ stated explicitly, but it is inferred from a Companion’s wording in some versions of Jābir’s ḥadith and others. Muslim, for example, reports through Abū al-Zubayr from Jābir that the Prophet ﷺ forbade eating onion and leek, yet necessity overpowered us…,” and so on.