Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:3:40

He said, "My Lord, how will I have a boy when I have reached old age and my wife is barren?" The angel said, "Such is Allah; He does what He wills."  

He said, ‘My Lord! How shall I have a boy, a son, when old age has overtaken me, that is, ˹after˺ I have reached extreme ˹old˺ age, 120 years ˹old˺; and my wife is barren?’, having reached the age of 98. He said, ‘So it, the matter, will be’, with God creating a boy from both of you. ‘God does what He will’, nothing can prevent Him therefrom, and in order to manifest this great power he was inspired with the question so that he would be answered through it ˹this great power˺. And when his soul longed for the swift fulfilment of that of which good tidings had been given:
القرآن:٣:٤٠

قَالَ رَبِّ أَنَّىٰ يَكُونُ لِي غُلَامٌ وَقَدْ بَلَغَنِيَ الْكِبَرُ وَامْرَأَتِي عَاقِرٌ ۖ قَالَ كَذَٰلِكَ اللَّهُ يَفْعَلُ مَا يَشَاءُ  

{قال ربِّ أنَّى} كيف {يكون لي غلام} ولد {وقد بلغني الكبر} أي بلغت نهاية السن مائة وعشرين سنة {وامرأتي عاقر} بلغت ثمانية وتسعين سنة {قال} الأمر {كذلك} من خلق الله غلاما منكما {الله يفعل ما يشاء} لا يعجزه منه شيء ولإظهار هذه القدرة العظيمة ألهمه السؤال ليجاب بها ولما تاقت نفسه إلى سرعة المبشَر به.

See similar narrations below:

Collected by Qurʾān
quran:19:8

He said, "My Lord, how will I have a boy when my wife has been barren and I have reached extreme old age?"  

He said, ‘My Lord, how shall I have a son when my wife is barren and I have reached infirm old age?’ (‘itiyyan, ˹derives˺ from ˹the verb˺ ‘atā, ‘it became withered’) in other words, ˹he had reached˺ extreme old age, 120 years; and his wife had reached the age of 98 (‘atiya in terms of its root derives from ‘utuwwun, but the tā’ is vowelled as -ti-, to soften it, the first wāw ˹vowel˺ is changed into a yā’ to be in harmony with the –ti- vowelling, while the second ˹wāw letter˺ is changed into a yā’ so that the ˹previous˺ yā’ can be assimilated with it).
القرآن:١٩:٨

قَالَ رَبِّ أَنَّىٰ يَكُونُ لِي غُلَامٌ وَكَانَتِ امْرَأَتِي عَاقِرًا وَقَدْ بَلَغْتُ مِنَ الْكِبَرِ عِتِيًّا  

{قال ربّ أنَّى} كيف {يكون لي غلام وكانت امرأتي عاقرا وقد بلغت من الكبر عتيا} من عتا: يبس، أي نهاية السن مائة وعشرين سنة وبلغت امرأته ثمانية وتسعين سنة وأصل عتى: عتو وكسرت التاء تخفيفا وقلبت الواو الأولى ياء لمناسبة الكسرة والثانية ياء لتدغم فيها الياء.