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

'Abdullah b. Mas'ud reported: Evil one is he who is evil in the womb of his mother and the good one is he who takes a lesson from the (fate of) others. The narrator came to a person from amongst the Companions of Allah's Messenger (PBUH) who was called Hudhaifa b. Usaid Ghifari and said: How can a person be an evil one without (committing an evil) deed? Thereupon the person said to him: You are surprised at this, whereas I have heard Allah's Messenger (PBUH) as saying: When forty-two nights pass after the semen gets into the womb, Allah sends the angel and gives him shape. Then he creates his sense of hearing, sense of sight, his skin, his flesh, his bones, and then says: My Lord, would he be male or female? And your Lord decides as He desires and the angel then puts down that also and then says: My Lord, what about his age? And your Lord decides as He likes it and the angel puts it down. Then he says: My Lord, what about his livelihood? And then the Lord decides as He likes and the angel writes it down, and then the angel gets out with his scroll of destiny in his hand and nothing is added to it and nothing is subtracted from it. Translation Not Available

Book reference: Sahih Muslim Book 46 Hadith 6393
Web reference: Sahih Muslim Book 33 Hadith 2645 a