[3:38] Then Zachariah prayed to his Lord, saying, 'Lord, bestow upon me from You a goodly offspring, verily You are the Hearer of supplication'.
i.e., when he saw the special gift (karāma) of God (s) with her, he grew more and more certain, and more and more hopeful, so he asked for a son in spite of his advanced age. The granting of his request was a rupture of ordinary reality (naq? al-āda).
It is said that Zachariah (ʿa) asked for a son to be a help to him in obedience, and an heir from his progeny in prophethood, so that he might uphold the right of God (ḥaqq Allāh). So it was a request which deserved to be granted. When a request is for the right of the Real (ḥaqq al-ḥaqq) and not for the pleasure of the self (ḥaẓẓ al-nafs) He will not refuse it. Zachariah (ʿa) saw Mary with summer fruits in the winter and winter fruits in the summer, so he asked for a son in his old age so that it might be a sign (āya) and a miracle (muʿjiza).