[Machine] While the Prophet Muhammad ﷺ was praying with his companions, he took off his sandals and placed them on his left side. So, they also took off their sandals. When he finished his prayer, he asked them, "What made you take off your sandals?" They replied, "We saw you taking off yours, so we took off ours too." He said, "Verily, Gabriel came to me or someone else came and informed me that there was something harmful or impure on them. So, when any of you come to the mosque, let him flip his sandals. If he sees something harmful, he should shake them off and pray in them."
بَيْنَمَا كان رَسُولُ اللَّهِ ﷺ يُصَلِّي بِأَصْحَابِهِ إِذْ خَلَعَ نَعْلَيْهِ فَوَضَعَهُمَا عَنْ يَسَارِهِ فَخَلَعُوا نِعَالَهُمْ فَلَمَّا قَضَى صَلَاتَهُ قَالَ «مَا حَمَلَكُمْ عَلَى إِلْقَائِكُمْ نِعَالَكُمْ؟» قَالُوا رَأَيْنَاكَ خَلَعْتَ فَخَلَعْنَا قَالَ «إِنَّ جِبْرِيلَ أَتَانِي أَوْ أَتَى فَأَخْبَرَنِي أَنَّ فِيهِمَا أَذًى أَوْ قَذَرًا فَإِذَا جَاءَ أَحَدُكُمُ الْمَسْجِدَ فَلْيُقَلِّبْ نَعْلَيْهِ فَإِنْ رَأَى فِيهِمَا أَذًى فَلْيُمِطْ وَلْيُصَلِّ فِيهِمَا»