عَنْ جَابِرِ بْنِ عَبْدِ اللَّهِ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ: ((إِذَا اسْتَقَرَّتِ النُّطْفَةُ فِي الرَّحِمِ أَرْبَعِينَ يَوْمًا أَوْ أَرْبَعِينَ لَيْلَةً بَعَثَ اللَّهُ إِلَيْهِ مَلَكًا فَيَقُولُ: يَا رَبِّ! مَا رِزْقُهُ؟ فَيُقَالُ لَهُ، فَيَقُولُ: يَا رَبِّ! مَا أَجَلُهُ؟ فَيُقَالُ لَهُ، فَيَقُولُ: يَا رَبِّ! ذَكَرٌ أَمْ أُنْثَى؟ فَيُعْلَمُ، فَيَقُولُ: يَا رَبِّ! شَقِيٌّ أَمْ سَعِيدٌ؟ فَيُعْلَمُ))
It is narrated from Sayyiduna Jabir bin Abdullah (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) said: "When the drop of fluid remains in the womb for forty days or nights, Allah Almighty sends an angel to it. Then the angel asks: O my Lord! What is its provision? So it is answered. Then he asks: O my Lord! When will its death be? So it is informed. Then he asks: O my Lord! Will it be male or female? So it is informed. Then he says: O my Lord! Will it be wretched or fortunate? Then this too is informed to him."