Sahih al-Bukhari 1884
Narrated Zaid bin Thabit:
When the Prophet (ﷺ) went out for (the battle of) Uhud, some of his companions (hypocrites) returned 
(home). A party of the believers remarked that they would kill those (hypocrites) who had returned, 
but another party said that they would not kill them. So, this Divine Inspiration was revealed: "Then 
what is the matter with you that you are divided into two parties concerning the hypocrites." (4.88) 
The Prophet (ﷺ) said, "Medina expels the bad persons from it, as fire expels the impurities of iron."
حَدَّثَنَا سُلَيْمَانُ بْنُ حَرْبٍ، حَدَّثَنَا شُعْبَةُ، عَنْ عَدِيِّ بْنِ ثَابِتٍ، عَنْ عَبْدِ اللَّهِ بْنِ يَزِيدَ، قَالَ سَمِعْتُ زَيْدَ بْنَ ثَابِتٍ ـ رضى الله عنه ـ يَقُولُ لَمَّا خَرَجَ النَّبِيُّ صلى الله عليه وسلم إِلَى أُحُدٍ رَجَعَ نَاسٌ مِنْ أَصْحَابِهِ فَقَالَتْ فِرْقَةٌ نَقْتُلُهُمْ‏.‏ وَقَالَتْ فِرْقَةٌ لاَ نَقْتُلُهُمْ‏.‏ فَنَزَلَتْ ‏{‏فَمَا لَكُمْ فِي الْمُنَافِقِينِ فِئَتَيْنِ‏}‏ وَقَالَ النَّبِيُّ صلى الله عليه وسلم ‏"‏ إِنَّهَا تَنْفِي الرِّجَالَ كَمَا تَنْفِي النَّارُ خَبَثَ الْحَدِيدِ ‏"‏‏.‏