the Messenger of Allah ruled that the child belonged to the bed.

Sunan Ibn Majah Book 9, Hadith 161