Sahih Bukhari | Volume 9 | Hadith Number 546

Narrated by 'Abdullah bin Mas'ud
Allah's Apostle the true and truly inspired, narrated to us, "The creation of everyone of you starts with the process of collecting the material for his body within forty days and forty nights in the womb of his mother. Then he becomes a clot of thick blood for a similar period (40 days) and then he becomes like a piece of flesh for a similar period. Then an angel is sent to him (by Allah) and the angel is allowed (ordered) to write four things; his livelihood, his (date of) death, his deeds, and whether he will be a wretched one or a blessed one (in the Hereafter) and then the soul is breathed into him. So one of you may do (good) deeds characteristic of the people of Paradise so much that there is nothing except a cubit between him and Paradise but then what has been written for him decides his behaviour and he starts doing (evil) deeds characteristic of the people of Hell (Fire) and (ultimately) enters Hell (Fire); and one of you may do (evil) deeds characteristic of the people of Hell (Fire) so much so that there is nothing except a cubit between him and Hell (Fire), then what has been written for him decides his behaviour and he starts doing (good) deeds characteristic of the people of Paradise and ultimately) enters Paradise." (See Hadith No. 430, Vol. 4)