Abdullah bin Masud reported,

The Messenger of Allah ﷺ, the truthful and trusted, narrated to us, saying, "Each one of you is gathered in his mother's womb for forty days," or he said, "forty nights." Waki said, "Forty nights." "Then he becomes a clinging clot for the same period, then a lump of flesh for the same period. Then Allah sends an angel to him with four commands, to record his deeds, his lifespan, his provision, and whether he will be wretched or blessed. Then the soul is breathed into him. By the One besides whom there is no god, one of you may perform the deeds of the people of Paradise until there is only a cubit between him and it, then what was written overtakes him and he ends his life with the deeds of the people of the Fire and so enters it. And one of you may perform the deeds of the people of the Fire until there is only a cubit between him and it, then what was written overtakes him and he ends his life with the deeds of the people of Paradise and so enters it."

Ahmad 4091

Sahih

حدثنا يحيى عن الأعمش ووكيع حدثنا الأعمش قال حدثنا زيد بن وهب

عن عبد الله قال

حدثنا رسول الله ﷺ وهو الصادق المصدوق قال إن أحدكم يجمع خلقه في بطن أمه في أربعين يوما أو قال أربعين ليلة قال وكيع ليلة ثم يكون علقة مثل ذلك ثم يكون مضغة مثل ذلك ثم يرسل الله عز وجل إليه الملك بأربع كلمات عمله وأجله ورزقه وشقي أو سعيد ثم ينفخ فيه الروح فوالذي لا إله غيره إن أحدكم ليعمل بعمل أهل الجنة حتى ما يكون بينه وبينها إلا ذراع فيسبق عليه الكتاب فيختم له بعمل أهل النار فيكون من أهلها وإن أحدكم ليعمل بعمل أهل النار حتى ما يكون بينه وبينها إلا ذراع فيسبق عليه الكتاب فيختم له بعمل أهل الجنة فيكون من أهلها

أحمد 4091صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Abdullah bin Masud
Numbering
Darussalam 4091
Ahmad 4091