Praise be to Allah.
Custody of the child is a right that is shared by the spouses if they are still married.
If divorce occurs, then the mother has more right to custody.
Al-‘Adawi al-Maliki said in his commentary on Sharh al-Khurashi (4/207): Custody belongs to the mother, if she is divorced or her husband dies.
But whilst she is still married, custody belongs to both spouses. End quote.
It says in al-Mawsu‘ah al-Fiqhiyyah (17/301): Custody of the child belongs to both parents, if they are still married.
If they separate, then custody belongs to the mother, according to scholarly consensus. End quote.
The mother has more right to custody of her children until the age of seven, so long as she has not remarried, because of the report narrated by Ahmad (6707) and Abu Dawud (2276) from ‘Abdullah ibn ‘Amr, who said: A woman said: O Messenger of Allah, my womb was a vessel for this son of mine, my breast gave him to drink, and my lap was a protection for him. But now his father has divorced me and wants to take him away from me. The Messenger of Allah (blessings and peace of Allah be upon him) said to her: “You have more right to him so long as you do not remarry.”
This hadith was classed as hasan by al-Albani in Sahih Abi Dawud.
But if she remarries, custody passes to the next in line.
Concerning that there was a difference of opinion among the jurists:
Some of them thought that it passes to the mother’s mother. This is the view of the majority in the four madhhabs.
Some of them thought that it passes to the father. This is the view favoured by Shaykh al-Islam Ibn Taymiyah and Ibn al-Qayyim.
See: al-Mawsu‘ah al-Fiqhiyyah (17/302) and ash-Sharh al-Mumti‘ (13/535).
If we say that custody passes to the father of the child, if he allows the child to remain with his mother who has remarried, and she is fit to take care of the child, and her second husband agrees to that, there is nothing wrong with it.
Similarly, the mother’s mother may give up custody to her daughter who has remarried.
Shaykh Ibn ‘Uthaymin said: Custody is the right of the one who can take care of the child, but it is not a duty.
Based on that, if he or she wants to give up custody to the next in line, it is permissible for him or her to do that."(Ash-Sharh al-Mumti‘ 13/536).
If the woman has not remarried and the child reaches the age of seven years:
If the child is male, he may be given the choice between his father and his mother, and he will live with the one whom he chooses, because of the report narrated by an-Nasa’i (3496) and Abu Dawud (2277) from Abu Hurayrah (may Allah be pleased with him), who said: I heard a woman who came to the Messenger of Allah (blessings and peace of Allah be upon him) when I was sitting with him and said: O Messenger of Allah, my husband wants to take my son away even though he brings me water from the well of Abu ‘Inabah and is of benefit to me.
The Messenger of Allah (blessings and peace of Allah be upon him) said: “Draw lots for him.”
Her husband said: Who is disputing my right to my child?
The Prophet (blessings and peace of Allah be upon him) said [to the child]: “This is your father and this is your mother; take the hand of whichever of them you wish.”
And the child took the hand of his mother, and she took him away.
This hadith was classed as sahih by al-Albani in Sahih Abi Dawud.
This is the view of the Hanbalis and Shafa‘is.
If the child is female, she may also be given the choice, according to ash-Shafa‘i (may Allah have mercy on him).
Abu Hanifah said: The mother has more right to her until the girl gets married or begins to menstruate.
Malik said: The mother has more right to her until she gets married and the husband consummates the marriage with her.
Ahmad said: The father has more right to her, because the father has more right to ensure her wellbeing.
See: al-Mawsu‘ah al-Fiqhiyyah (17/314-317).
Custody ends when the child reaches puberty and the age of maturity, at which time he may choose whichever he wishes of his parents. The child also has the right to live separately from them if he is male.
Ibn Qudamah (may Allah have mercy on him) said: No one is entitled to custody over anyone else except a child or one who has an intellectual disability. As for one who is an adult of mature thinking, there is no need for custody of him, and he has the choice to live with whichever of his parents he wishes.
If he is a man, then he has the right to live alone, because he has no need of them, but it is recommended for him not to live apart from them so that he will not stop honouring them.
If the child is female, she cannot live on her own, and her father should prevent her from doing that, because there is no certainty that someone may come to her and corrupt her, thus bringing shame upon her and her family. If she does not have a father, then her guardian and her family should prevent her from doing that."(Al-Mughni 8/191).
Spending on the children’s maintenance during custody is the duty of the father.
After the custody ends, when the children reach puberty and become mature, then there is a difference of opinion among the jurists regarding the duty of spending on their maintenance.
If an adult son is poor, then his rich father is obliged to spend on him. If there is no father, then his rich mother must spend on him, according to the Hanbalis, whether he is healthy or incapacitated.
According to the Shafa‘is, that becomes obligatory if the child is incapacitated due to a chronic condition or illness.
It says in al-Insaf (9/289): The words “and his children, no matter how far the line of descent reaches” also include adult children who are healthy and strong, if they are poor. This is correct, and it is the view of the madhhab. End quote.
Ibn Qudamah said: And ash-Shafa‘i said: There should be a condition that there is something wrong with him, either in terms of discernment or physically.
Abu Hanifah said: The father should spend on the boy until he reaches puberty, then if he reaches puberty and is healthy, the duty to spend on him ceases, but the duty to spend on a daughter is not waived until she gets married.
Malik said something similar, except that he said that spending on daughters should continue until they get married and their husbands consummate the marriage with them, then there is no spending on them even if they get divorced. But if they get divorced before consummation of the marriage, then [the father] should still spend on them.
And we have the words of the Prophet (blessings and peace of Allah be upon him) to Hind: “Take what is sufficient for you and your children on a reasonable basis.” He did not exempt the child who is mature and healthy, and because the child is poor, he deserves maintenance from his rich father, just as is the case if the child is chronically ill or blind."(Al-Mughni 9/258).
From this we may learn that so long as the father is alive, the woman does not have to spend on her children after custody ends, whether that is to buy a house or anything else, and that the father is required to spend on his daughter until she gets married.
And Allah knows best.