The Prophet ﷺ saw some phlegm on the wall of the qiblah, and it troubled him so much that the displeasure showed on his face. He stood up and scraped it off with his own hand, then said, "When one of you stands in prayer, he is conversing privately with his Lord," or he said, "his Lord is between him and the qiblah. So none of you should spit in the direction of the qiblah, but rather to his left, or under his foot."Then he took the edge of his cloak, spat into it, folded one part over the other, and said, "Or he may do like this."
أن النبي ﷺ رأى نخامة في القبلة، فشق ذلك عليه، حتى رئى في وجهه، فقام فحكه بيده، فقال: إن أحدكم إذا قام في صلاته، فإنه يناجي ربه، أو إن ربه بينه وبين القبلة، فلا يبزقن أحدكم قبل قبلته، ولكن عن يساره، أو تحت قدميه ثم أخذ طرف ردائه فبصق فيه، ثم رد بعضه على بعض فقال: أو يفعل هكذا.
Bukhari related it in the Book of Prayer (412, 413), and Muslim in the Book of Mosques (551), both from the hadith of Shuba, who said, Qatada told me, he said, I heard Anas bin Malik narrate it, and he mentioned it.Bukhari also related it (405) through another route, from Humayd, from Anas, and this is his wording. Muslim did not mention, "Then he took the edge of his cloak..."