Sayyiduna Abu Sa'id Khudri and Sayyiduna Abu Hurairah (may Allah be pleased with them both) reported that the Messenger of Allah (peace and blessings of Allah be upon him) saw phlegm on the wall of the (Prophet's) Mosque, so he scraped it off with a pebble. Then the Messenger of Allah (peace and blessings of Allah be upon him) said: "When any of you spits (during prayer), he should not spit in front of him nor to his right side, but rather to his left side or under his foot."
Brief Explanation
(Commentary on Hadiths 1432 to 1436)
Spittle, mucus, phlegm, and expectoration are natural bodily fluids. In conditions such as catarrh and cold, a person is compelled to expel and clear them. Now, if someone is performing prayer, what should he do in such a situation? All praise be to the pure Islamic Shari‘ah, which has clarified every matter, leaving nothing concealed. In such a case, the ruling is that the one praying should not spit in front of him or to his right, but rather to his left, or under his foot, or on the edge of his garment or a handkerchief, and then rub it in.
In the present era, the best means for this are tissues or paper napkins, which are permissible to use during prayer.
In the early days of Islam, mosques—especially the Prophet’s Mosque—were unpaved and without flooring or prayer mats. Therefore, the ruling was that if someone, out of necessity, did spit, he did a wrong act, and its expiation is that it should be buried with soil or scraped away. The Seal of the Messengers, sallallahu alayhi wa sallam, himself, when he saw phlegm or spittle in the mosque or on the wall, scraped it away or indicated for it to be scraped away, as has been mentioned in detail in the aforementioned hadiths.
Mosques are the houses of Allah; in them, Allah is worshipped, His remembrance and supplication take place, and they are the best places on the face of the earth. Their respect demands that mosques be kept pure and clean from filth. Rather, the mosque should be adorned with perfume and fragrance, and with clean floors and carpets, and there is great virtue for the one who does so.
In the aforementioned hadiths, the reason mentioned for not spitting in front is that “Allah is before him.” The scholars and hadith experts have interpreted this to mean that Allah’s mercy is before him, and it does not mean at all that Allah Himself is physically present before every worshipper, as is the belief of some Sufis, Jahmiyyah, and innovators. For Allah is above the Throne: «﴿الرَّحْمٰنُ عَلَى الْعَرْشِ اسْتَوَىٰ﴾ [طه : 5]». His knowledge, His mercy, His seeing, and His hearing encompass the entire world and all of creation (wa huwa as-sami‘ al-‘alim).
The scholars have mentioned other explanations as well. For details, see: Fath al-Bari, Sharh al-Nawawi, and other commentaries on hadith.
The ruling for not spitting to the right is because on the right side is the angel who records good deeds, [كما فى رواية البخاري 416]. For details, see: [فتح الباري 663/1].
The summary of all these hadiths is that spitting in the mosque, expelling mucus from the nose, or expectorating is a sin and disrespectful.
Respect for the mosque and consideration for the comfort and ease of the worshippers is necessary. Spitting or blowing the nose should be done either outside the mosque, or in such a way—using tissue paper, napkins, or a handkerchief—that those sitting nearby do not find it repulsive. This should be observed both during prayer and outside of it, because in some narrations, the phrase “when he prays” is mentioned, and in others, there is a general ruling that one should neither spit, nor blow the nose, nor expel phlegm in the mosque.
«واللّٰه أعلم وعلمه أتم».