Sunan Abi Dawud, Book 2, Hadith 86 (Abu Dawud 476)

Anas b. Malik reported:

The Messenger of Allah(ﷺ) said: Spitting phlegm in the mosque... The narrator then transmitted the rest of the tradition to the same effect.