حَدَّثَنِي أَبُو كَامِلٍ، فُضَيْلُ بْنُ حُسَيْنٍ الْجَحْدَرِيُّ حَدَّثَنَا حَمَّادُ بْنُ زَيْدٍ، حَدَّثَنَا عُبَيْدُ، اللَّهِ بْنُ أَبِي بَكْرٍ عَنْ أَنَسِ بْنِ مَالِكٍ، وَرَفَعَ الْحَدِيثَ، أَنَّهُ قَالَ ‏"‏ إِنَّ اللَّهَ عَزَّ وَجَلَّ قَدْ وَكَّلَ بِالرَّحِمِ مَلَكًا فَيَقُولُ أَىْ رَبِّ نُطْفَةٌ أَىْ رَبِّ عَلَقَةٌ أَىْ رَبِّ مُضْغَةٌ ‏.‏ فَإِذَا أَرَادَ اللَّهُ أَنْ يَقْضِيَ خَلْقًا - قَالَ - قَالَ الْمَلَكُ أَىْ رَبِّ ذَكَرٌ أَوْ أُنْثَى شَقِيٌّ أَوْ سَعِيدٌ فَمَا الرِّزْقُ فَمَا الأَجَلُ فَيُكْتَبُ كَذَلِكَ فِي بَطْنِ أُمِّهِ ‏"‏ ‏.‏

Anas b. Malik reported directly from Allah's Messenger (PBUH) that he said: Allah, the Exlated and Glorious, has appointed an angel as the caretaker of the womb, and he would say: My Lord, it is now a drop of semen; my Lord, It is now a clot of blood; my Lord, it has now become a lump of flesh, and when Allah decides to give it a final shape, the angel says: My Lord, would it be male or female or would he be an evil or a good person? What about his livelihood and his age? And it is all written as he is in the womb of his mother. Translation Not Available

Book Ref: Sahih Muslim Book 46 Hadith 6397
Web Ref:  Sahih Muslim Book 33 Hadith 2646