Al-Kāfi
Hadith 46مُحَمَّدُ بْنُ يَحْيَى عَنْ أَحْمَدَ بْنِ مُحَمدٍ عَنِ ابْنِ فَضَّالٍ عَنِ الْحَسَنِ بْنِ الْجَهْمِ قَالَ: سَمِعْتُ أَبَا الْحَسَنِ الرِّضَا (عليه السلام) يَقُولُ: قَالَ أَبُو جَعْفَرٍ (عليه السلام) إِنَّ النُّطْفَةَ تَكُونُ فِي الرَّحِمِ أَرْبَعِينَ يَوْماً ثُمَّ تَصِيرُ عَلَقَةً أَرْبعينَ يَوْماً ثُمَّ تَصِيرُ مُضْغَةً أَرْبَعِينَ يَوماً، فَإِذَا كَمَلَ أَرْبَعَةُ أَشْهُرٍ بَعَث اللَّهُ مَلَكيْنِ خَلَّاقَيْنِ فَيَقُولَانِ يَا ربّ مَا تَخْلُقُ ذَكَراً أَوْ أُنْثَى فَيُؤْمَرَانِ فَيَقُولَانِ يَا رَبِّ شَقِيّاً أَوْ سَعِيداً فَيُؤْمَرَانِ فَيقُولَانِ يَا رَبِّ مَا أَجَلُهُ وَ مَا رِزْقُهُ وَ كُلُّ شَيْءٍ مِنْ حَالِهِ وَ عَدَّد مِنْ ذَلِك أَشْيَاءَ وَ يَكْتُبَانِ الْمِيثاقَ بَيْنَ عَيْنَيْهِ، فَإِذَا أَكْمَلَ اللَّهُ لَهُ الأَجَلَ بَعَثَ اللَّهُ مَلَكاً فَزَجَرَهُ زَجرَةً فَيَخرُجُ وَ قَدْ نَسِيَ الْمِيثَاقَ. فَقَالَ الْحَسَنُ بْنُ الْجَهْمِ: فَقُلْتُ لَهُ: أَ فَيَجُوزُ أَن يَدْعُوَ اللَّهَ فَيُحَوِّلَ الْأُنْثَى ذكَراً وَ الذَّكَرَ أنْثَى؟ فَقَالَ: إِنَّ اللَّهَ يَفْعَلُ مَا يَشَاءُ.
3. Muhammad ibn Yahya has narrated from Ahmad ibn Muhammad from Ibn Faddal from al-Hasan ibn al-Jahm that he heard Abul Hasan al-Ridha (as) say: Abu Ja'far (al-Baqir) (as) said: "Sperm in the womb after forty days becomes a clot, and then after another forty days becomes a fetus. When four months pass by, Allah sends two creating angels and they ask, “Oh Lord, what do You want to create, male or female?". They are then commanded accordingly. Then they ask, "Oh Lord, do You want him to be miserable or happy?". They are then commanded accordingly. Then they ask, "When is his term (of death)? What is his sustenance and its quantity?". They then write the covenant (of monotheism) between his eyes. When God's appointed time (i.e. pregnancy) for the fetus comes, He sends an angel to prompt it, causing it to emerge and emerges forgotten about the covenant (of monotheism)." Al-Hasan ibn al-Jahm asked him (Imam al-Ridha): "Would Allah a change a female into a male, or a male into a female, if someone were to supplicate to him for that?". So he said: "Indeed Allah does what He wills".