(2) باب فَضْلِ الْمَدِينَةِ، وَأَنَّهَا تَنْفِي النَّاسَ
Narrated Abu Huraira:
Allah's Messenger (ﷺ) said, "I was ordered to migrate to a town which will swallow (conquer) other towns and is called Yathrib and that is Medina, and it turns out (bad) persons as a furnace removes the impurities of iron.
Reference: Sahih al-Bukhari 1871
In-book reference: Book 29, Hadith 5
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 3, Book 30, Hadith 95