It is narrated from Hazrat Abu Huraira (may Allah be pleased with him) that the Holy Prophet (peace and blessings be upon him) said: Whoever spits in the mosque should go far away; if he cannot do so, then he should spit into his garment.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 10889