Narrated Abu Huraira:

Allah's Messenger (ﷺ) was asked, "Who are the most honorable of the people?" The Prophet (ﷺ) said, "The most honorable of them in Allah's Sight are those who keep their duty to Allah and fear Him. They said, "We do not ask you about that." He said, "Then the most honorable of the people is Joseph, Allah's prophet, the son of Allah's prophet, the son of Allah's prophet, the son of Allah's Khalil i.e. Abraham) They said, "We do not ask you about that." The Prophet (ﷺ) said, Do you ask about (the virtues of the ancestry of the Arabs?" They said, "Yes," He said, "Those who were the best amongst you in the Prelslamic Period are the best amongst you in Islam if they comprehend (the Islamic religion).

حَدَّثَنِي مُحَمَّدٌ، أَخْبَرَنَا عَبْدَةُ، عَنْ عُبَيْدِ اللَّهِ، عَنْ سَعِيدِ بْنِ أَبِي سَعِيدٍ، عَنْ أَبِي هُرَيْرَةَ ـ رضى الله عنه ـ قَالَ سُئِلَ رَسُولُ اللَّهِ صلى الله عليه وسلم أَىُّ النَّاسِ أَكْرَمُ قَالَ ‏"‏ أَكْرَمُهُمْ عِنْدَ اللَّهِ أَتْقَاهُمْ ‏"‏‏.‏ قَالُوا لَيْسَ عَنْ هَذَا نَسْأَلُكَ‏.‏ قَالَ ‏"‏ فَأَكْرَمُ النَّاسِ يُوسُفُ نَبِيُّ اللَّهِ ابْنُ نَبِيِّ اللَّهِ ابْنِ نَبِيِّ اللَّهِ ابْنِ خَلِيلِ اللَّهِ ‏"‏‏.‏ قَالُوا لَيْسَ عَنْ هَذَا نَسْأَلُكَ‏.‏ قَالَ ‏"‏ فَعَنْ مَعَادِنِ الْعَرَبِ تَسْأَلُونِي ‏"‏‏.‏ قَالُوا نَعَمْ‏.‏ قَالَ ‏"‏ فَخِيَارُكُمْ فِي الْجَاهِلِيَّةِ خِيَارُكُمْ فِي الإِسْلاَمِ إِذَا فَقِهُوا ‏"‏‏.‏ تَابَعَهُ أَبُو أُسَامَةَ عَنْ عُبَيْدِ اللَّهِ‏.‏
USC-MSA web (English) reference : Vol. 6, Book 60, Hadith 211
Arabic reference : Book 65, Hadith 4689