[Machine] The Messenger of Allah ﷺ prayed in his sandals, and the people prayed in their sandals. Then he removed his sandals and the people removed their sandals while they were still in prayer. When he finished his prayer, he asked, "What made you throw your sandals in prayer?" They replied, "O Messenger of Allah, we saw you do so, so we did the same." He said, "Indeed, Jibril (Gabriel), ﷺ , informed me that there was impurity in them. So, when any one of you enters the mosque, let him look at his sandals. If he sees any impurity on them, then he should remove them. If not, then let him pray in them."
أَنَّ رَسُولَ اللهِ ﷺ صَلَّى فِي نَعْلَيْهِ فَصَلَّى النَّاسُ فِي نِعَالِهِمْ ثُمَّ أَلْقَى نَعْلَيْهِ فَأَلْقَى النَّاسُ نِعَالَهُمْ وَهُمْ فِي الصَّلَاةِ فَلَمَّا قَضَى صَلَاتَهُ قَالَ مَا حَمَلَكُمْ عَلَى إِلْقَاءِ نِعَالِكُمْ فِي الصَّلَاةِ؟ قَالُوا يَا رَسُولَ اللهِ رَأَيْنَاكَ فَعَلْتَ فَفَعَلْنَا فَقَالَ إِنَّ جَبْرَائِيلَ عَلَيْهِ السَّلَامُ أَخْبَرَنِي أَنَّ فِيهَا أَذًى فَإِذَا أَتَى أَحَدُكُمُ الْمَسْجِدَ فَلْيَنْظُرْ فَإِنْ رَأَى فِي نَعْلَيْهِ أَذًى وَإِلَّا فَلْيُصَلِّ فِيهِمَا