The Prophet ﷺ said, "The rider travels behind the funeral procession, while the one on foot may walk behind it, in front of it, to its right, or to its left, staying close to it. The miscarried child is prayed over, and forgiveness and mercy are invoked for its parents."
أن النبي ﷺ قال: الراكب يسير خلف الجنازة، والماشي يمشي خلفها وأمامها، وعن يمينها وعن يسارها قريبا منها، والسقط يصلى عليه، ويدعى لوالديه بالمغفرة والرحمة.
Narrated by Abu Dawud (3180), Tirmidhi (1031), Ibn Majah (1481, 1507), and Nasai (1943), all through various routes from Ziyad bin Jubayr bin Hayya, from his father, from Mughira bin Shuba, as mentioned. The wording given is Abu Dawud's, while the wording of the others is, "The prayer is performed over the child." Tirmidhi said, "Hasan sahih." Ibn Hibban (3049) graded it sahih, as did Hakim (1/355, 363), who said, "Sahih according to the criterion of Bukhari."The miscarried fetus is that which falls from its mother's womb before completion. If it has completed four months, the funeral prayer is performed over it, because the breathing of the soul into it has been completed by that point. Before that, the prayer is not performed over it, because it is not a dead person, but rather a clot of blood or a lump of flesh. Tirmidhi said, "This is acted upon by some of the scholars among the companions of the Prophet ﷺ and others, who said that the prayer is performed over the child even if it did not cry out, once it is known that it has been formed. This is the view of Ahmad and Ishaq."This is supported by the hadith of Ibn Masud, as a saying of the Prophet, "Indeed the creation of each of you is gathered in his mother's womb for forty days, then it is a clot of blood for a similar period, then it is a lump of flesh for a similar period, then an angel is sent... who breathes the soul into it." This is sahih and was given in full earlier in the Book of Faith.I say, Shafii held two positions. The second position is that the prayer is not performed over the child until it cries out. He perhaps based this on the hadith of Jabir bin Abdullah, who said, the Messenger of Allah said, "The child is not prayed over, does not inherit, and is not inherited from, until it cries out." Narrated by Tirmidhi (1032) and Ibn Majah (1508), both through the route of Abu Zubayr, from Jabir bin Abdullah, as mentioned.Tirmidhi said, "This is a hadith concerning which people have differed greatly. Some of them narrated it from Abu Zubayr, from Jabir, from the Prophet, as his direct saying, while Ashath bin Sawwar and more than one other narrated it from Abu Zubayr, from Jabir, as Jabir's own statement without attributing it to the Prophet, and Muhammad bin Ishaq narrated it from Ata bin Abu Rabah, from Jabir, likewise as Jabir's own statement. It seems that this is more sahih than the version attributed directly to the Prophet." End of quote.Ibn Qattan Fasi said, "It comes through the narration of Abu Zubayr from Jabir using the ambiguous form 'an, without the narration of Layth from him, and this is a defect. Moreover, it also comes through the narration of Ismail bin Muslim Makki from Abu Zubayr, and he is very daif."I say, it was also narrated by Ibn Hibban (6032) and Hakim (4/348, 349), both through the hadith of Ishaq Azraq, who said, Sufyan Thawri narrated to us, from Abu Zubayr, from Jabir, from the Prophet, who said, "If the child cries out, the prayer is performed over it and it inherits." For more, see Nasb Raya (2/277).The conclusion regarding the hadith of Jabir is that it suffers from considerable inconsistency, as Tirmidhi stated.