He then instructed him to eat and clarified that what prevented him ﷺ from partaking of it was his constant connection with his Lord and the private conversation to which no one else has access; therefore, when drawing near to his Lord, majestic and exalted, he must be in the best possible state.
Rulings derived from the two hadiths:
1 – It is prohibited for anyone who has eaten garlic, onion, or leek to enter the mosques.
2 – Anything with an offensive odor that disturbs the angels or the worshippers falls under the same ruling, such as the smell of tobacco used by smokers. Whoever is afflicted with that habit must refrain from it when going to the mosque and should clean his teeth and mouth until the odor is removed or at least diminished.
3 – It is disliked for someone who is obliged to attend the prayer in the mosque to eat these foods, lest he miss the congregational prayer—unless he does so as a trick to avoid attending, in which case it becomes unlawful.
4 – The wisdom behind forbidding entry to the mosques is to spare the angels and the worshippers any harm.
5 – Harming others is forbidden by every means. Since this particular means is explicitly mentioned, extending the ruling to similar cases by analogy is valid.
6 – Abstaining from garlic and the like is not because they are unlawful; the Prophet’s ﷺ command to eat them proves that his own abstention does not imply prohibition.
Benefit:
Some scholars have argued that eating these foods is permissible because the congregational prayer is a farḍ kifāyah (communal obligation).
Their inference is that, were it a farḍ ʿayn (individual obligation), one would be required to avoid anything that prevents attendance at the congregational prayer in the mosques.
In fact, their reasoning is unsound, for performing a permissible act that incidentally leads to the suspension of a duty is not blameworthy so long as it is not adopted as a ruse to nullify that duty—just as undertaking a permissible journey in Ramadan allows one to break the fast during the daytime without sin, provided the journey was not made solely to obtain that concession.