It is narrated from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) narrated to us, and he (peace and blessings be upon him) is the truthful and the one confirmed as truthful: "Indeed, the creation of each one of you is gathered in his mother's womb for forty nights; then for a similar period he is an 'alaqah (a clinging clot); then for a similar period he is a mudghah (a lump of flesh). Then the angel comes to him and says: 'O my Lord, is it male or female? Is it wretched or fortunate? What is its provision? And what is its term (the time of death)?' Then your Lord decrees, and the angel writes it down."
Hadith Referenceالمعجم الأوسط / باب الألف / 1717
Hadith Takhrij«أخرجه البخاري فى «صحيحه» برقم: 3208، 3332، 6594، 7454، ومسلم فى «صحيحه» برقم: 2643، 2645، وابن حبان فى «صحيحه» برقم: 6174، 6177، والنسائي فى «السنن الكبرى» برقم: 11182، وأبو داود فى «سننه» برقم: 4708، والترمذي فى «جامعه» برقم: 2137 (م 1)، 2137، 2137 (م 2)، والدارمي فى «مسنده» برقم: 213، وابن ماجه فى «سننه» برقم: 76، والبيهقي فى «السنن الكبرى» برقم: 15522، 15519، 21338، وأحمد فى «مسنده» برقم: 3623، 3694، 4012، 4172، والطيالسي فى «مسنده» برقم: 296، والحميدي فى «مسنده» برقم: 126، وأبو يعلى فى «مسنده» برقم: 5157، والبزار فى «مسنده» برقم: 1447، 1551، 1636، 1766، 1763، 1764، 1765، وابن حجر فى «المطالب العالية» برقم: 3125 / 2، وعبد الرزاق فى «مصنفه» برقم: 20076، 20093، والطحاوي فى «شرح مشكل الآثار» برقم: 3861، 3862، 3866، 3863، 3864، 3865، 3867، 3868، 3869، 3870، (9/479) [دون رقم في الترقيم المختار]، والطبراني فى «الكبير» برقم: 3038، 3036، 3041، 3040، 3045، 3043، 8518، 8519، 8520، 8529، 8530، 8527، 8528، 8531، 8884، 8885، 9146، 10440، والطبراني فى «الصغير» برقم: 200، 442، والطبراني فى «الأوسط» برقم: 2631، 4559»