While the Messenger of Allah ﷺ was leading his companions in prayer, he removed his sandals and placed them on his left side. When the people saw this, they too took off their sandals.When the Messenger of Allah ﷺ finished the prayer, he asked, "What made you take off your sandals?"They replied, "We saw you take off your sandals, so we took off ours."The Messenger of Allah ﷺ said, "Jibreel came to me and informed me that there was filth," or he said, "something offensive on them. So when one of you comes to the mosque, let him examine his sandals. If he finds any filth or offensive matter on them, let him wipe it off and pray in them."
بينما رسول الله ﷺ يصلي بأصحابه إذ خلع نعليه، فوضعهما عن يساره، فلما رأى ذلك القوم ألقوا نعالهم، فلما قضى رسول الله ﷺ صلاته قال: ما حملكم على إلقاء نعالكم؟ قالوا: رأيناك ألقيت نعليك فألقينا نعالنا. فقال رسول الله ﷺ: إن جبريل عليه السلام أتاني، فأخبرني أن فيها قذرا أو قال: أذى وقال: إذا جاء أحدكم إلى المسجد فلينظر، فإن رأى في نعليه قذرا، أو أذى فليمسحه وليصل فيهما.
Abu Dawud (650) narrated it from Musa bin Ismail, from Hammad, from Abu Naama Saadi, from Abu Nadra, from Abu Saeed Khudri, and he related the same account. Its isnad is sahih, and Hammad here is Ibn Salama, as is confirmed in Musnad Imam Ahmad (11153). Ibn Khuzayma (1017) and Hakim (1/260) both graded it sahih, both transmitting it through Hammad bin Salama. Hakim said, "Sahih according to the standard of Muslim."