The Prophet ﷺ said, "Allah puts an angel in charge of the uterus and the angel says, 'O Lord, (it is) semen! O Lord, (it is now ) a clot! O Lord, (it is now) a piece of flesh.' And then, if Allah wishes to complete its creation, the angel asks, 'O Lord, (will it be) a male or a female? A wretched (an evil doer) or a blessed (doer of good)? How much will his provisions be? What will his age be?' So all that is written while the creature is still in the mother's womb." (Using translation from Bukhārī 6595)
"إِنَّ الله تَبَارَك -وَتَعَالى- قَدْ وَكَّلَ بالرَّحِم مَلَكًا يَقولُ: أَيْ رَبِّ، نُطفَةٌ، أَيْ رَبِّ عَلَقَةٌ، أي رَبِّ مُضْغَةٌ. فَإذَا أرَادَ الله -تَعَالى- أن يَقْضِي خَلقَها قَال: أي رَبِّ شَقِيٌّ أوْ سَعَيِدٌ؟ ذَكَرٌ أَوْ أُنثَى؟ فَمَا الرِّزْقُ؟ فَما الأجَلُ؟ فَيُكْتَبُ كَذِلكَ فِي بَطنِ أُمِّهِ".