عَنْ عَمْرِو بْنِ شُعَيْبٍ عَنْ أَبِيهِ عَنْ جَدِّهِ رَضِيَ اللَّهُ عَنْهُ أَنَّ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ قَضَى أَنَّ كُلَّ مُسْتَلْحَقٍ يُسْتَلْحَقُ بَعْدَ أَبِيهِ الَّذِي يُدْعَى لَهُ ادَّعَاهُ وَرَثَتُهُ مِنْ بَعْدِهِ فَقَضَى إِنْ كَانَ مِنْ أَمَةٍ يَمْلِكُهَا يَوْمَ أَصَابَهَا فَقَدْ لَحِقَ بِمَنِ اسْتَلْحَقَهُ وَلَيْسَ لَهُ فِيمَا قُسِمَ قَبْلَهُ مِنَ الْمِيرَاثِ شَيْءٌ وَمَا أَدْرَكَ مِنْ مِيرَاثٍ لَمْ يُقْسَمْ فَلَهُ نَصِيبُهُ وَلَا يُلْحَقُ إِذَا كَانَ أَبُوهُ الَّذِي يُدْعَى لَهُ أَنْكَرَهُ وَإِنْ كَانَ مِنْ أَمَةٍ لَا يَمْلِكُهَا أَوْ مِنْ حُرَّةٍ عَاهَرَ بِهَا فَإِنَّهُ لَا يُلْحَقُ وَلَا يَرِثُ وَإِنْ كَانَ أَبُوهُ الَّذِي يُدْعَى لَهُ هُوَ الَّذِي ادَّعَاهُ وَهُوَ وَلَدُ زِنًا لِأَهْلِ أُمِّهِ مَنْ كَانُوا حُرَّةً أَوْ أَمَةً
It is narrated from Sayyiduna Abdullah bin Amr bin al-As (may Allah be pleased with them both) that the Noble Prophet (peace and blessings be upon him and his family) issued this ruling: that a boy or girl whose lineage has been attributed to his father, in whose name he is called and to whom he is connected, after the death of his father, and then if there are claimants to that boy or girl after the death of that father, and regarding the slave woman as well, the Prophet (peace and blessings be upon him and his family) gave the same ruling: that the one who was her owner on the day he had intercourse with her, the lineage of the child will be attributed to him, to the one who has demanded the attribution of lineage. However, if the inheritance of the father has already been distributed before the attribution of lineage, then the one to whom the lineage is attributed will not receive any share from it, and if he attains the inheritance that has not yet been distributed, then he will receive a share from it. And if the person to whom the boy or girl is attributed denies it, and if the child is from a slave woman whom he did not own, or from a free woman with whom he committed adultery, then in this case, the child will neither be attributed to his lineage nor will the boy or girl inherit from him. And if the father for whom the boy or girl is called claims him, whether from a slave woman or a free woman, then he is a child of adultery.