Ibn Shihab said that the funeral prayer is performed over every infant who dies, even if born out of wedlock, because the child was born upon the natural disposition of Islam. If both parents claim Islam, or even just the father, while the mother follows another religion, the prayer is still performed over the child provided it cried aloud at birth. The prayer is not performed over one who did not cry at birth, since it is considered a stillbirth.Abu Hurairah used to relate that the Prophet ﷺ said, "There is no newborn except that it is born upon the natural disposition. Then its parents make it a Jew, a Christian, or a Magian, just as an animal gives birth to a whole and complete offspring. Do you find any mutilation in it?"Then Abu Hurairah
would recite, "The natural disposition of Allah upon which He created mankind" [Rum 30:30].
حدثنا أبو اليمان أخبرنا
ابن شهاب يصلى على كل مولود متوفى وإن كان لغية من أجل أنه ولد على فطرة الإسلام يدعي أبواه الإسلام أو أبوه خاصة وإن كانت أمه على غير الإسلام إذا استهل صارخا صلي عليه ولا يصلى على من لا يستهل من أجل أنه سقط فإن أبا هريرة رضي الله عنه كان يحدث قال النبي ﷺ ما من مولود إلا يولد على الفطرة فأبواه يهودانه أو ينصرانه أو يمجسانه كما تنتج البهيمة بهيمة جمعاء هل تحسون فيها من جدعاء ثم يقول أبو هريرة رضي الله عنه {فطرة الله التي فطر الناس عليها} الآية