Question :
Is it permissible for a praying person to leave the congregational prayer because those next to him have eaten garlic or onions or have been smoking, and this is making it hard for him to maintain submissiveness during prayer?
The Answer :
All perfect praise be to Allah, The Lord of The Worlds, and may His peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
Leaving obligatory prayer is impermissible, since Allah, The most Exalted, said (What means):" and render not your actions vain." [Muhammad/33]. "In general, it is prohibited to leave prayer, be it obligatory or voluntary." [Hashyat Amira Ala' Sharih Al-Minhaj 1/291].
Being a collective duty, it is reprehensible to leave congregational prayer save for a sound excuse, such as bad odors emitted from other praying people. In such case, one is permitted not to follow the Imam and to continue his prayer alone, but fast and he is excused, Inshallah.
Furthermore, Al-Imam Al-Sharwani( May Allah have mercy on his soul) said (What means):" To avoid harming prayer performers, whosoever ate anything that has bad odor is permitted not to follow the Imam, and he will attain the reward of performing the congregational prayer." Since this exception is given to such person, other prayer performers, in this case, are permitted to pray alone."
Al-Khatib Ashrbini (May Allah have mercy on his soul) reported, in his book [Mughni Al-Muhtaj 1/511], the following Hadith:" Mu’adh bin Jabal Al-Ansari led his companions in the ‘Isha’ prayer and he made it long. A man among us went away and prayed by himself. He went to the Messenger of Allah (PBUH) and told him what Mu’adh had said to him." Al-Imam Ash-Shirbini commented on the aforementioned Hadith:" That the Prophet (PBUH) denied what Mu'adh said to the man, didn't deny the man's action nor asked him to repeat his prayer indicates that it is permissible to leave the congregation for an excuse".
In conclusion, we advise whosoever is inflicted with smoking or who ate onions or garlic not to attend the congregational prayer in order not to harm the praying people and to avoid such a sin. Further, Al-Imam An-Nawawi (May Allah have mercy on his soul) said (What means):" There is no excuse for not attending congregational prayer save for the following: heavy rain, strong storm at night time, heavy mud, sickness or eating anything that has bad odor." [Mughni Al-Muhtaj 1/476]. And Allah knows best.