For some time, he had noticed signs of pregnancy in his wife. Therefore, he became curious about the gender of their child.
He himself hoped for a son, and after nine months of pregnancy, his wife gave birth to a healthy boy. He then took pen and paper to write a letter to Imam Hadi (peace be upon him):
In the name of God
From Yahya bin Zakariya to Abu al-Hasan Ali bin Muhammad al-Hadi
Peace be upon you,
If possible, please pray to God to grant us a son.
In response to Yahya bin Zakariya’s letter, Imam Hadi (peace be upon him) wrote: “Perhaps a daughter may be better than a son.”
After some time, Yahya’s wife gave birth to a daughter.[1]
Through this response, Imam Hadi (peace be upon him) made it clear to Yahya that the gender of the child is not what matters; it is God’s will and the fate He has decreed. As He Himself says in the Quran: “God knows what each pregnant woman carries” [2]. Therefore, in the prayer taught to us in the Quran for requesting children from God, gender is not mentioned; what is requested is a pure and righteous child [3]. Thus, whether the child is a son or a daughter is not the issue, but rather what God wills, not our desires.
Footnotes:
[1] Kashf al-Ghummah, vol. 2, p. 385 — Al-Khara’ij wa al-Jara’ih, vol. 1, p. 398
[2] (Surah Ar-Ra’d, verse 8)
[3] (Surah Al-Imran, verse 38)