The Prophet ﷺ was asked, "Who is the noblest of people?"He replied, "The noblest of them is the most God-fearing."They said, "Prophet of Allah, this is not what we are asking about."He said, "Then the noblest of people is Yusuf, prophet of Allah, son of the prophet of Allah, son of the prophet of Allah, son of the friend of Allah."They said, "This is not what we are asking about either."He asked, "Are you asking me about the lineages of the Arabs?"They said, "Yes."He said, "The best of you in the age of ignorance are the best of you in Islam, provided they gain understanding of the religion."
قيل للنبي ﷺ: من أكرم الناس؟ قال: أكرمهم أتقاهم قالوا: يا نبي الله ليس عن هذا نسألك قال: فأكرم الناس يوسف نبي الله ابن نبي الله ابن نبي الله ابن خليل الله قالوا: ليس عن هذا نسألك قال: فعن معادن العرب تسألوني؟ قالوا: نعم قال: فخياركم في الجاهلية خياركم في الإسلام إذا فقهوا.
Bukhari narrated it in the Hadiths of the Prophets (3374), and Muslim in the Virtues (2378), both through various routes from Ubaydullah, from Saeed bin Abu Saeed Maqburi, from Abu Hurairah, who said, and then he narrated it.