Abu Tufayl narrated that he said, "I visited Abu Sariha Huzaifa bin Usayd al-Ghifari, and he said, 'I heard the Messenger of Allah ﷺ with these two ears of mine saying, "The drop of fluid settles in the womb for forty nights, then the angel takes form over it."'"Zuhayr said, "I think he said, 'the one who fashions it.'""The angel says, 'My Lord, male or female?' So Allah makes it male or female. Then he says, 'My Lord, sound in form or not sound in form?' So Allah makes it sound or not sound. Then he says, 'My Lord, what is its provision? What is its lifespan? What is its disposition?' Then Allah makes it wretched or happy."
أن أبا الطفيل حدثه قال: دخلت على أبي سريحة حذيفة بن أسيد الغفاري فقال: سمعت رسول الله ﷺ بأذني هاتين يقول: إن النطفة تقع في الرحم أربعين ليلة، ثم يتصور عليها الملك. قال زهير: حسبته قال الذي يخلقها: فيقول: يا رب أذكر أو أنثى؟ فجعله الله ذكرا أو أنثى، ثم يقول: يا رب أسوي أو غير سوي؟ فيجعله الله سويا أو غير سوي. ثم يقول: يا رب ما رزقه؟ ما أجله؟ ما خلقه؟ ثم يجعله الله شقيا أو سعيدا.
Muslim narrated it in the Chapter on Divine Decree (2645:4), from Muhammad bin Ahmad bin Abu Khalaf, who said, Yahya bin Abu Bukayr told us, Zuhayr Abu Khaythama told us, Abdullah bin Ata told me, that Ikrima bin Khalid told him, and he mentioned it.