In Sahīh al-Bukhārī and Sahīh Muslim, it is reported of the Prophet—may Allah bless him and grant him peace:
“He was asked, ‘Who are the noblest people?’ He replied, ‘Those who are most mindful of Allah.’
“They said, ‘That is not what we are asking you about (1).’ He replied, ‘Joseph, the prophet of Allah, son of Jacob, the prophet of Allah, son of Isaac, the prophet of Allah, son of Abraham, the close friend of Allah.’
“They said, ‘That is not what we are asking you about (2).’ He replied, ‘Then is it (3) the lineages of the Arabs that you are asking me about (4)? The best of them in the age of ignorance are the best of them in Islam, provided they gain understanding of the religion.’” (5)
He first explained to them that the noblest of all people in Allah’s sight are those most mindful of Him, even if they are neither the sons nor the fathers of prophets. Thus Abraham the prophet—may Allah bless him and grant him peace—is nobler in Allah’s sight than Joseph, even though Abraham’s father was Āzar, whereas Joseph’s father was Jacob. Likewise, Noah is nobler in Allah’s sight than Israel, even though Israel’s children were prophets, whereas Noah’s children were not.
When they explained that they were asking only about lineage, he told them that the noblest in terms of lineage are those descended from the prophets. Among Adam’s descendants, there is none like Joseph, for he was a prophet, the son of a prophet, the grandson of a prophet.
When they indicated that they meant only what concerned themselves, he said:
“Are you, then, asking me about the lineages of the Arabs? People are mines, like mines of gold and silver. The best of them in the age of ignorance are the best of them in Islam, provided they gain understanding of the religion.”
He explained that lineages are like mines: a man is born of his lineage just as gold and silver are produced from a mine.