وَإِنِّي خِفْتُ الْمَوَالِيَ مِن وَرَائِي وَكَانَتِ امْرَأَتِي عَاقِرًا فَهَبْ لِي مِن لَّدُنكَ وَلِيًّا
(Zachariah invoked his Lord,) “I have fears in regard to my kinsmen after me, and my wife is barren. So bestow upon me a successor out of Your grace!” (Maryam 19:5)
It is not accurate to interpret Zachariah’s asking his Lord for a son as his being displeased with the Divine Destiny. For his desire for a son was due to certain significant aims. First of all, Zachariah, upon him be peace, was a Prophet sent to the Children of Israel, who had hitherto been guided and governed by Prophets. With respect to his grave concern for the guidance of his people, we can, as an example, remember the attitude of the Children of Israel when Saul was appointed as a commander over them by their Prophet (Samuel) at that time. Thus, Prophet Zachariah, who grew old and did not yet have any children, prayed to God for a son, worrying that his people would possibly fail to acknowledge and pay heed to the one who would succeed him, and the unity of the Children of Israel would be destroyed.
This verse can also be viewed from a different perspective as follows:
Human beings are tested with any worldly thing they desire. We can cite the examples of the Prophets Abraham and Zachariah, upon them be peace. Abraham had a secret desire to have a son, as it can be understood from the fact that he rejoiced when the angel gave the good news of a child to him and his wife. As for Zachariah, he asked for a child explicitly. In accordance with Divine Wisdom, both Prophets were tested with their children. Since Abraham had not voiced his inner desire, he was tested with the Divine command to slaughter his elder son Ishmael as a sacrifice, but God sent a ram in place of Ishmael before Abraham fulfilled the command in obedience to it. However, since Zachariah voiced his desire, he was tested with the slaughter of himself and his son by his people. They were put to severe tests although these tests brought positive results as well. Everybody is tested according to their level. The Prophets Abraham and Zachariah, upon them be peace, were among those who are the nearest to God. The test of those near-stationed to God is extremely difficult.
Zachariah’s fear or worry was that he would be deprived of one who would succeed him in both his religious and worldly duties. It is because of this that he prayed to God for a good, upright son, who would be an heir to him in both the mission of Prophethood and in representing the House of Jacob. He thus said, “My Lord! Do not let me leave the world without an heir, for You are the Best of the inheritors” (Al-Anbiyā’ 21:89), and, “My Lord, bestow upon me out of Your grace a good, upright offspring” (Āl ‘Imrān 3:38).
As stated in the hadīth, “We, the community of Prophets, do not bequeath; whatever we leave is charity,” no Prophet worried about bequeathing anything worldly to their inheritors. Therefore, Zachariah’s plea for a son to succeed him was in regards to his mission among his people and as the representative of the House of Jacob. God, the Best of the inheritors, accepted his prayer and in order to stress that His bestowing on him a son was purely out of His grace, He granted him John, upon him be peace, despite the fact that Zachariah was too old to have a son, and his wife was barren. However, He took John back after he performed his mission of, “confirming a Word (Jesus) from God” (Āl ‘Imrān 3:39), and after setting a good example by “holding fast to the Book” and “being dutiful to parents” (Maryam 19:12–14). Thus we are reminded that it is He Himself Who is the True Inheritor.
 “Their Prophet said to them: ‘God has set up Saul for you as king.’ They said: ‘How can he have kingdom over us when we are more deserving of kingdom than him?’…” (Al-Baqarah 2:247).
 Bukhārī, I’tisam, 5; Khumus, 1; Nafaqat, 3; Fadāil Ashabi’n-Nabī, 12; Farāid, 3; Muslim, Jihād, 51–52, 54, 56; al-Asbahānī, Dalāilu’n-Nubuwwah, 1/138.