It is narrated from Sayyiduna Abu Sa'id (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) led the prayer wearing his sandals, and the people also prayed in their sandals. Then he (peace and blessings be upon him) took off his sandals, and the people also took off their sandals while still in the prayer. When he (peace and blessings be upon him) completed the prayer, he said: "What made you take off your sandals during the prayer?" They said: O Messenger of Allah! We saw you do (so), so we did the same. He (peace and blessings be upon him) said: "Jibril (peace be upon him) informed me that there was filth on them. When one of you comes to the mosque, he should look: if he sees filth on his sandals, he should take them off; otherwise he should pray in his sandals."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 4086