(79) باب إِذَا أَسْلَمَ الصَّبِيُّ فَمَاتَ هَلْ يُصَلَّى عَلَيْهِ وَهَلْ يُعْرَضُ عَلَى الصَّبِيِّ الإِسْلاَمُ
Narrated Ibn Shihab:
The funeral prayer should be offered for every child even if he were the son of a prostitute as he was born with a true faith of Islam (i.e. to worship none but Allah Alone). If his parents are Muslims, particularly the father, even if his mother were a non-Muslim, and if he after the delivery cries (even once) before his death (i.e. born alive) then the funeral prayer must be offered. And if the child does not cry after his delivery (i.e. born dead) then his funeral prayer should not be offered, and he will be considered as a miscarriage. Abu Huraira, narrated that the Prophet (ﷺ) said, "Every child is born with a true faith (i.e. to worship none but Allah Alone) but his parents convert him to Judaism or to Christianity or to Magainism, as an animal delivers a perfect baby animal. Do you find it mutilated?" Then Abu Huraira recited the holy verses: 'The pure Allah's Islamic nature (true faith i.e. to worship none but Allah Alone), with which He has created human beings.' " (30.30).
Reference: Sahih al-Bukhari 1358
In-book reference: Book 23, Hadith 112
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 2, Book 23, Hadith 440