Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) narrated that the Messenger of Allah (peace and blessings be upon him) said: "The child belongs to (the owner of) the bed."
Imam Ahmad (may Allah have mercy on him) recorded it from Sufyan (may Allah have mercy on him).
It is narrated from Abu Yazid (may Allah have mercy on him) that he said: Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) was seated in al-Hijr (the Hatim), and he sent for a man of Banu Zuhrah from our neighbourhood who had lived in the time of Jahiliyyah, and he came to him. The narrator said: I also went with him. When he reached him, he asked him about the building of the Ka'bah. He said: "Quraysh exerted all their strength in building it, but they could not meet its expenses, and they made it smaller (than its original foundation); so they built the Ka'bah and left part of it in the Hatim." Sayyiduna Umar (may Allah be pleased with him) said: "You have spoken the truth." Then he asked him about a birth from the days of Jahiliyyah, and the old man said: "As for the sperm, it was from so-and-so, and as for the child, it was (born) on the bed of so-and-so." Sayyiduna Umar (may Allah be pleased with him) said: "You have spoken the truth, but the Messenger of Allah (peace and blessings be upon him) ruled in favour of (the owner of) the bed."
Ubaydullah bin Adi bin al-Khiyar (may Allah have mercy on him) also narrated something similar from Sayyiduna Umar (may Allah be pleased with him).