Short Answer
Be patient and know that this is the will of Allah. Say “inna lillahi wa inna ilayhi rājiʿūn”. Know that Allah will reward you if you pass this difficult test.
If the fetus was was born alive for even a moment then it must be given a name, ghusl, shrouded, prayed over, and buried with Muslims like any other child. Another opinion is that this must be done if the fetus reached 120 days since it had a soul. Otherwise the fetus will not be given a name, no ghusl will be done, no janazah will be performed, and it will just be wrapped in a cloth and buried anywhere. An ʿaqīqah is not recommended unless the baby lived for seven days.
What the Qur’an Says
“˹He is the One˺ Who created death and life in order to test which of you is best in deeds. And He is the Almighty, All-Forgiving.” 67:2
What the Sunnah Says
“The miscarried fetus should be prayed over (the funeral prayer), and supplication for forgiveness and mercy for his parents should be offered.” (Abu Dawud; Al-Albani said it is authentic in Sahih al-Jami`, 3525)
What the Scholars Said
“The scholars are unanimously agreed that if it is known to have lived and its cry has been heard, the prayer should be offered for it. But if its cry is not heard, Imam Ahmad said: “If it has completed four months [gestation], then it should be washed and the funeral prayer offered.” (al-Mughni, 2:328)
Version 0.20
Shaykh Mustafa Umar