Sayyiduna Anas bin Malik (may Allah be pleased with him) narrates: The Prophet (peace and blessings be upon him) took off his sandals during prayer only once. (Seeing him,) the people also took off their sandals. (After the prayer,) the Prophet (peace and blessings be upon him) asked: Why have you taken off your sandals? The people submitted: We saw that you took them off, so we took ours off too. The Prophet (peace and blessings be upon him) said: Jibril informed me that there was filth on them.
Tabarani recorded it in al-Mu'jam al-Awsat, and its narrators are the narrators of the Sahih. Bazzar recorded it in abridged form.
Hadith Referenceمجمع الزوائد ومنبع الفوائد / كتاب الصلاة / 2260