Sahih Muslim , Hadith 2643

Abdullah (b. Mas'ud) reported that Allah's Messenger who is the most truthful (of the human beings) and his being truthful (is a fact) said: Verily your creation is on this wise. The constituents of one of you are collected for forty days in his mother's womb in the form of blood, after which it becomes a clot of blood in another period of forty days. Then it becomes a lump of flesh and forty days later Allah sends His angel to it with instructions concerning four things, so the angel writes down his livelihood, his death, his deeds, his fortune and misfortune. By Him, besides Whom there is no god, that one amongst you acts like the people deserving Paradise until between him and Paradise there remains but the distance of a cubit, when suddenly the writing of destiny overcomes him and he begins to act like the denizens of Hell and thus enters Hell, and another one acts in the way of the denizens of Hell, until there remains between him and Hell a distance of a cubit that the writing of destiny overcomes him and then he begins to act like the people of Paradise and enters Paradise.

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

sunnah.com

This hadith has been reported on the authority of A'mash with the same chain of transmitters and in the hadith transmitted on the authority of Waki' (the words are): " The creation of any one of you is like this that (semen) is collected in the womb of the mother for forty nights," and in the hadith transmitted on the authority of Shu'ba (the words are):" Forty nights and forty days." And in the hadith transmitted on the authority of Jarir and 'Isa (the words are):" Forty days."

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

sunnah.com