Sahih Bukhari
Beginning of Creation
Volume: 004 / Book Number: 054 / Hadith Number: 430
Narrated 'Abdullah bin Mus'ud:
Allah's Apostle, the true and truly inspired said, "(The matter of the Creation of) a human being is put together in the womb of the mother in forty days, and then he becomes a clot of thick blood for a similar period, and then a piece of flesh for a similar period. Then Allah sends an angel who is ordered to write four things. He is ordered to write down his (i.e. the new creature's) deeds, his livelihood, his (date of) death, and whether he will be blessed or wretched (in religion). Then the soul is breathed into him. So, a man amongst you may do (good deeds till there is only a cubit between him and Paradise and then what has been written for him decides his behavior and he starts doing (evil) deeds characteristic of the people of the (Hell) Fire. And similarly a man amongst you may do (evil) deeds till there is only a cubit between him and the (Hell) Fire, and then what has been written for him decides his behavior, and he starts doing deeds characteristic of the people of Paradise."