Jami` at-Tirmidhi, Book 6, Hadith 29 (Tirmidhi 572)

Anas bin Malik narrated that :

the Messenger of Allah said: "To spit in the Masjid is a sin, and burying it is its atonement."