Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) said: The Prophet (peace and blessings be upon him) was leading the Companions (may Allah be pleased with them) in prayer when he (peace and blessings be upon him) suddenly took off his shoes and placed them on his left side. When the Companions (may Allah be pleased with them) saw this, they too took off their shoes. When he (peace and blessings be upon him) finished the prayer, he asked: "Why did you take off your shoes?" They said: "We saw you (peace and blessings be upon him) take off your shoes, so we took ours off too." He (peace and blessings be upon him) said: "Jibril (peace be upon him) told me that there was filth on them." Then he (peace and blessings be upon him) said: "When you come to the prayer, look at your shoes; if there is filth on them, wipe it off and pray in them."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 4249