How should one handle expectoration (spitting) while praying in the mosque?

Chapter on what invalidates the prayer if omitted intentionally or forgetfully

Al-Mughni

Book of Prayer

Book 3 · Issue 6 · Bab 6

Open in Qurani

Primary text

If phlegm escapes while one is praying in the mosque, one should spit into one's garment and rub that part against another part of the garment. If one is outside the mosque, one should spit to the left or under one's foot. The evidence is the narration from Muslim, via Abu Hurayrah, where the Prophet (peace be upon him) saw phlegm on the Qibla side of the mosque and instructed that spitting should be to the left or under the foot, or by wiping it onto the garment, as he demonstrated by spitting into his garment and wiping it across itself. Spitting in the mosque is a sin, and its expiation is covering it up (burying it), as narrated by Muslim.