The Messenger of Allah ﷺ said, "When one of you spits in my mosque or any mosque, let him dig and bury it deep, or let him spit into his garment and carry it out."
حدثنا وكيع حدثنا أبو مودود عن عبد الرحمن بن أبي حدرد الأسلمي
قال رسول الله ﷺ إذا بزق أحدكم في مسجدي أو المسجد فليحفر وليعمق أو ليبزق في ثوبه حتى يخرجه
Its isnad is sahih, it passed at 7522, and Abu Mawdud is Abdul-Aziz bin Abu Sulayman Hudhali, their client, the judge of Madinah, a trustworthy and virtuous man. Haythami said, "Its narrators are considered reliable," Majma 2/18. The hadith is in the Sahihayn with the same meaning, related by Bukhari 1/113 in the Book of Prayer, chapter on the atonement for spitting, and Muslim 2/390, number 552, and Tirmidhi 572, all of them from Anas.