While the Messenger of Allah ﷺ was leading his companions in prayer, he removed his sandals and placed them to his left. When the people saw this, they took off their sandals as well. 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 harmful on them." Then he said, "When one of you comes to the mosque, let him check his sandals. If he finds filth or something harmful on them, let him wipe it off and pray in them."
حدثنا موسى بن إسمعيل حدثنا حماد بن سلمة عن أبي نعامة السعدي عن أبي نضرة
بينما رسول الله ﷺ يصلي بأصحابه إذ خلع نعليه فوضعهما عن يساره فلما رأى ذلك القوم ألقوا نعالهم فلما قضى رسول الله ﷺ صلاته قال ما حملكم على إلقاء نعالكم قالوا رأيناك ألقيت نعليك فألقينا نعالنا فقال رسول الله ﷺ إن جبريل ﷺ أتاني فأخبرني أن فيهما قذرا أو قال أذى وقال إذا جاء أحدكم إلى المسجد فلينظر فإن رأى في نعليه قذرا أو أذى فليمسحه وليصل فيهما
Its isnad is sahih.Ahmad reported it, 20/3, from the hadith of Hammad bin Salama with this chain. Ibn Khuzayma graded it sahih, h: 1017, as did Ibn Hibban, h: 360, and Hakim, who said it meets the criteria of Muslim, 1/260, and Dhahabi agreed with him. Bayhaqi reported it, 2/431, from the hadith of Abu Dawud with this chain.