The Messenger of Allah ﷺ said, "Any person whose lineage is claimed after the death of the father to whom he is attributed, his heirs claiming him after the father has died, it is judged that if he was born of a slave woman whom the father owned at the time he had relations with her, then he is attached in lineage to the one who claims him. He has no share, however, in any inheritance that was distributed before the claim was made. As for any inheritance he reaches that has not yet been distributed, he receives his share. He is not attached in lineage if the father to whom he is attributed denied him during his lifetime. If he was born of a slave woman the father did not own, or of a free woman with whom he had committed fornication, then he is not attached in lineage and does not inherit. Even if the man to whom he is attributed himself claimed him, he is a child of fornication, belonging to his mother's people, whether they be free or slaves."Muhammad bin Rashid said, "He means by this whatever inheritance had been distributed during the Jahiliyyah, before Islam."
أن رسول الله ﷺ قال: كل مستلحق استلحق بعد أبيه الذي يدعى له، ادعاه ورثته من بعده، فقضي أن من كان من أمة يملكها يوم أصابها فقد لحق بمن استلحقه، وليس له فيما قسم قبله من الميراث شيء، وما أدرك من ميراث لم يقسم فله نصيبه، ولا يلحق إذا كان أبوه الذي يدعى له أنكره. وإن كان من أمة لا يملكها، أو من حرة عاهر بها فإنه لا يلحق ولا يورث. وإن كان الذي يدعى له هو ادعاه فهو ولد زنا، لأهل أمه من كانوا حرة أو أمة. قال محمد بن راشد: يعني بذلك ما قسم في الجاهلية قبل الإسلام.
Reported by Abu Dawud (2265), Ibn Majah (2746), Ahmad (7042), Hakim (4/342), Bayhaqi (6/260), and Darimi (3154), all from the hadith of Muhammad bin Rashid, from Sulayman bin Musa, from Amr bin Shuayb, from his father, from his grandfather, who related it.Its chain of transmission is hasan because of Sulayman bin Musa, who is the Damascene known as Ashdaq, and his teacher Amr bin Shuayb, for both of them make the hadith hasan.