Allaah, may He be Blessed and Exalted, says:
"This is the time when Zakariya invoked his Lord, saying: 'O my Lord! Grant me from You, a good offspring. You are indeed the All-Hearer of invocations.'" [Surah Aali 'Imraan: 38]
And He says quoting Zakariya:
"And verily, I fear my relatives after me, since my wife is barren. So give me from Yourself a walee (righteous worshipper) who will inherit me and inherit the posterity of Ya'qoob. And make him, my Lord, one with whom You are well-pleased." [Surah Maryam: 5-6]
Ash-Shanqeetee said in Adwaa-ul-Bayaan: "Allaah's statement in this noble verse: 'So give me from Yourself a walee' - what is meant by the word walee here is a son specifically and not any other type of walee (righteous person). This is based on proof found in Allaah's saying while relating the same story: 'This is the time when Zakariya invoked his Lord, saying: 'O my Lord! Grant me from You, a good offspring. You are indeed the All-Hearer of invocation.'' [Surah Aali 'Imraan: 38]
Allaah also indicates that what is meant (by the word walee, i.e. righteous person) here is a child by His saying:
"And remember Zakariya when he cried to his Lord: 'O my Lord, leave me not single! You are the best of the inheritors.''' [Surah Al-Anbiyaa: 89]
'Leave me not single' means: 'Alone and without a child.'" [End of Ash-Shanqeetee's words]
It is for this reason that from amongst the supplications of the believers - "those from whom We shall accept the best of their deeds and overlook their evil deeds, they shall be among the dwellers of Paradise - a promise of truth, which they have been promised"2 - is that which Allaah has mentioned:
"My Lord! Grant me the power and ability that I may be grateful for Your Favor which You have bestowed upon me and upon my parents, and that I may do righteous good deeds, such as please You, and make my offspring good. Truly, I have turned to You in repentance, and truly I am one of the Muslims." [Surah Al-Ahqaaf: 15]
Footnotes:
2 Surah Al-Ahqaaf: 15