The Prophet (ﷺ) said, "Spitting in the mosque is a sin and its expiation is to bury it."
Sahih al-Bukhari Book 8, Hadith 65