All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
To vow one's child to Allaah Almighty is not a valid or binding vow. A vow is a commitment that the person imposes upon himself to offer something that he possesses or do an action that he is able to do. To vow one's child to Allaah, however, means that one makes a vow concerning that which he does not possess and commits someone other than himself to do a certain act of obedience. It was narrated that the Prophet, sallallaahu ‘alayhi wa sallam, said: "There is no fulfillment of a vow which involves disobeying Allaah or that which is made concerning something that the son of Adam does not possess." [Abu Daawood]
As for the statement of the mother or Maryam (Mary), may Allaah exalt her mention, which is related by Allaah Almighty in the verse (which means): {My Lord, indeed I have vowed to You what is in my womb, consecrated [for Your service]…} [Quran 3: 35], she vowed her child to serve Bayt Al-Maqdis (the masjid of Jerusalem) and be fully devoted to the worship of Allaah Almighty. This was permissible in their legislation.
Al-Qurtubi commented on the verse, saying: "Such a practice was permissible in their legislation, and their children were required to obey."
Ash-Shawkani said: "Such a vow was permissible in their legislation."
However, this is not permissible in Islam. Ibn Al-‘Arabi said: "The scholars unanimously agree that it is invalid for one to vow his child in whatever manner he may wish…"
There is a difference in opinion among the scholars regarding what a person who vows to slaughter his child is required to do.
According to Hanafi scholars and a report of the Hanbali scholars such a person is required to slaughter a sheep.
The Maaliki scholars have the opinion that he is required to slaughter a sheep if he intended to offer his child as a sacrifice in Hajj (pilgrimage). Otherwise, he is required to offer expiation for breaking an oath.
The Hanbali scholars say that an expiation for breaking an oath is due in such a case.
The Shaafi‘i scholars hold the opinion that this type of vow constitutes disobedience for which the vow maker should ask Allaah for forgiveness and that he is not required to do anything else. This is the sound opinion because a man slaughtering his child is prohibited in Islam, and one should not fulfill a vow that involves disobedience to Allaah Almighty. Likewise, when one says, "I dedicate my son as an endowment (Waqf) for Allaah", then his endowment is invalid. For an endowment to be valid, it is conditioned that one possesses the thing he wants to state as an endowment, and it must be a sellable item. These conditions, however, are not met in the case of a child. Whoever does so, his endowment is invalid and it is not binding.
Allaah Knows best.