Sa'id bin al-Musayyib or Abu Salamah (the doubt is from Sufyan) narrates from Abu Hurayrah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "The child belongs to the (owner of the) bed, and for the adulterer is the stone."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب اللعان / 15329
Ubaydullah bin Abi Yazid narrates from his father that Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) sent for an elderly man of Banu Zuhrah who used to live in our house. I took him to Sayyiduna Umar bin al-Khattab (may Allah be pleased with him), and he asked him about a birth from among the births of the Jahiliyyah (pre-Islamic era). He said: As for the bed, it belongs to so-and-so, and as for the sperm, it belongs to so-and-so. Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) said: You have spoken the truth, but the Messenger of Allah (peace and blessings be upon him) gave judgment "in favour of the bed."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب اللعان / 15330
Al-Hasan bin Sa'd narrates from Rabah: My family married me to a Roman slave-girl of theirs. I went in to her, and she gave birth to a black child, and I named him Abdullah. Then I went in to her again, and she gave birth to a black child like me, and I named him Ubaydullah. He says: Then a slave of ours named Birjis formed a relationship with her; he spoke to her in his own language, and she gave birth to a child like a gecko. I said to her: What is this? She said: This is the son of Birjis. The matter reached Sayyiduna Uthman bin Affan (may Allah be pleased with him); when the slave-girl was questioned, she confessed. Sayyiduna Uthman bin Affan (may Allah be pleased with him) said: Are you both content that I judge between you with the judgment of the Messenger of Allah (peace and blessings be upon him)? The Messenger of Allah (peace and blessings be upon him) "judged the child to belong to the owner of the bed (the one on whose bed it was born)." Mahdi says: I think the slave and the slave-girl were flogged.
(b) In the narration of al-Rudhbari the name is Yuhannah. He says: I think Mahdi said that when the two of them (the slave and the slave-girl) were questioned, they confessed. At its end it says that both of them were flogged, and they were both slaves.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب اللعان / 15331
Muhammad bin Abdullah bin Abi Ya'qub narrates from Rabah something of the same meaning, and at its end it says that the Messenger of Allah (peace and blessings be upon him) "judged the child to belong to the owner of the bed, and for the adulterer is the stone." He is your son: you inherit from him and he inherits from you. I said: "Subhan Allah (Glory be to Allah)!" He said: "That is how it is." So I used to put him to sleep between the two of them: these two are black and this one is white.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب اللعان / 15332