Praise be to Allah
The scholars differed concerning the relationship between Zakariyya and Maryam (peace be upon them both). There are two views:
That he was the husband of her sister
That he was the husband of her maternal aunt.
See the answer to question no. 82569.
It was narrated that Zakariyya (peace be upon him) was also one of the paternal cousins of Maryam (peace be upon her), in addition to being the husband of her maternal aunt or sister. See: al-Hidaayah by Makki (2/999).
Allah, may He be glorified and exalted, has told us about Zakariyya’s sponsorship (kafaalah) of Maryam, as He said (interpretation of the meaning):
“So her Lord accepted her with good acceptance and caused her to grow in a good manner and put her in the care [kaffalaha] of Zechariah [Zakariyya]”
[Aal ‘Imraan 3:37].
What is meant by kafaalah [sponsorship or taking care] is that he looked after her affairs and needs. Kafaalah includes taking care of the interests of the person under one’s care, spending on him, and looking after his needs.
Ibn ‘Atiyah (may Allah have mercy on him) said: What it means is that he took her into his care and spent on her. The kaafil (sponsor) is the one who takes care of another.
End quote from al-Muharrar al-Wajeez (1/425).
Al-Waahidi (may Allah have mercy on him) said: He took her into his care and looked after her affairs.
Az- Zajjaaj said: What is meant is that he took care of her affairs. … The kaafil is the one who sponsors a person, looks after him and spends on him..
End quote from at-Tafseer al-Baseet (5/203).
Ibn Katheer said: Here our Lord is telling us that He accepted the vow of her mother, and that He “caused her to grow in a good manner” that is, He made her good-looking and endeared her to peopler, and caused her to be in the company of the righteous among His slaves, so that she could learn goodness, knowledge and religion from them.
Hence Allah says: “and put her in the care [kaffalaha] of Zechariah [Zakariyya]”; the grammatical structure of this phrase in the original Arabic indicates that Zakariyya was made to be her sponsor or carer.
Ibn Ishaaq said: That was only because she was an orphan.
Other scholars stated that the Children of Israel were stricken by a famine, so Zakariyya sponsored Maryam and took care of her because of that.
There is no contradiction between the two views. And Allah knows best.
The reason why Allah decreed that Zakariyya should be her sponsor was because this would be in her best interests, so that she might learn a great deal of beneficial knowledge and righteous deeds from him, and because he was the husband of her maternal aunt, according to what was mentioned by Ibn Ishaaq, Ibn Jareer, and others.
It was also said that he was the husband of her sister.
Ibn ‘Ashoor said: When Maryam was born, her father had died, and a number of the rabbis of the Children of Israel disputed over who was to sponsor her, for they were all keen to sponsor the daughter of their senior rabbi. They drew lots for that, and the lot fell to Zakariyya. What appears to be the case is that the matter of her sponsorship was delegated to the rabbis because she was dedicated to the service of the place of worship, so it was essential that she be given a righteous upbringing for that reason.
At-Tahreer wa’t-Tahreer (2/235).
It was narrated that Zakariyya was one of the paternal cousins of Maryam, and he was the husband of her sister or maternal aunt. He was her sponsor (kaafil), meaning that he used to take care of her needs and look after her.