It is narrated from Sayyiduna Abdullah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him), the truthful and the one confirmed as truthful, said: "The creation of each of you is gathered in his mother's womb for forty days; then it becomes a clinging clot in the same way; then it becomes a lump of bones and flesh in the same way. Then Allah Almighty sends the angel, who breathes his soul into him. Then he is commanded with four words: to write his provision, his deeds, his term of life, and (whether) he will be fortunate or wretched. By the One besides whom there is no god! One of you does the deeds of the people of Hell until there remains between him and Hell only an arm's length; then the decree overtakes him, his end is sealed with the deeds of the people of Paradise, and he enters it. And one of you does the deeds of the people of Paradise until there remains between him and Paradise only an arm's length; then the decree overtakes him, his end is sealed with the deeds of the people of Hell, and he enters Hell."
Imam Muslim recorded it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب العدد / 15421
It is narrated from Anas bin Malik (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Allah has placed an angel in charge of the womb. He says: O my Lord, a drop of sperm! O my Lord, a clinging clot! O my Lord, a lump of flesh! Then when Allah wills to decree its creation, the angel says: O my Lord, male or female? Wretched or fortunate? What is its provision, and what is the term of its life? All of this is written while it is still in its mother's womb."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب العدد / 15422
It is narrated from Sayyiduna Hudhayfah bin Asid (may Allah be pleased with him), who traced it back to the Prophet (peace and blessings be upon him), that the Prophet (peace and blessings be upon him) said: "The angel is appointed over the drop of sperm after it has settled in the womb for forty or forty-five days, and the angel says: O my Lord, will this one be wretched or fortunate? Allah Almighty speaks, and it is written whether it is wretched or fortunate. Then he says: O my Lord, male or female? Allah Almighty speaks, and it is written whether it is male or female. Then its deeds and the time of its death are also written, and its provision and the traces it will leave behind are also written. Then the scrolls are rolled up, and nothing is added to them and nothing is taken away."
Muslim recorded it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب العدد / 15423
It is narrated from Abu al-Zubayr al-Makki that Amir bin Wathilah narrated to him that he heard Abdullah bin Mas'ud (may Allah be pleased with him) saying: The wretched one is he who was wretched in his mother's womb, and the fortunate one is he who takes admonition from others. A man from the Companions of the Prophet (peace and blessings be upon him) came, whose name was Hudhayfah bin Asid al-Ghifari (may Allah be pleased with him). He (Amir) told him this saying of Abdullah bin Mas'ud (may Allah be pleased with him) and said: How can a man be wretched without having done any deeds? The man said to him: Do you wonder at that? I heard the Messenger of Allah (peace and blessings be upon him) saying: "When forty-two nights have passed over the drop of sperm, Allah Almighty sends an angel to it, who shapes it and creates its hearing, its sight, its skin, its flesh and its bones. Then he says: 'O my Lord, male or female?' Your Lord decrees what He wills, and the angel writes it down. He says: 'O my Lord, his term of life?' Your Lord says what He wills, and the angel writes it down. Then the angel says: 'O my Lord, his provision?' Your Lord decrees what He wills, and the angel writes it down. Then he goes out with the scroll in his hand, and nothing is added to the matter and nothing is taken away."
Muslim recorded it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب العدد / 15424
And it has been mentioned that Abdullah bin Mas'ud (may Allah be pleased with him) said: The waiting period of a pregnant woman is until she delivers what is in her womb.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب العدد / 15425