Sayyiduna Abu Huraira (may Allah be pleased with him) narrates: The Messenger of Allah (peace and blessings be upon him) said: "The child belongs to the one on whose bed it is born."
Hadith Referenceمسند اسحاق بن راهويه / كتاب الفرائض / 735
Hadith Takhrij«بخاري ، كتاب الفرائض ، باب الولد للفراش الخ ، رقم : 6818/6750 . مسلم ، كتاب الرضاع ، باب الولد للفراش وتوفي الشبهات ، رقم : 1458 .»
Explanation & Benefits
Hafiz Abdush Shakoor Tirmidhi
Benefits: From the mentioned hadith, it is understood that the child will be attributed to the one on whose bed he was born; he is the father of the child, even if someone committed adultery with the child's mother, and even if, due to adultery, the child resembles someone other than the father, and even if someone else claims to be the father of the child. However, if the father himself denies the child, then the child will be attributed to the mother. The meaning of attributing and affiliating the child to the father is that the mutual rulings between father and son, such as inheritance, etc., will apply between them.
The majority of the scholars have stipulated a condition for affiliating the child to the father: that the father must have had intercourse (mujami‘at) with the child's mother. However, Imam Abu Hanifah rahimahullah has adopted the position that merely the establishment of the marriage contract (nikah) is sufficient to affiliate the child to the father, whether intercourse took place or not.
Shaykh al-Islam Ibn Taymiyyah rahimahullah has stated that for affiliating the child to the father, it is necessary that intercourse with the woman be established. (Subul al-Salam: 3/521) A hadith is coming ahead in which there will be further clarification, insha Allah.