The mother has more right to custody of her children before the age of seven so long as she does not remarry, in which case the right passes to the one who is most entitled to that after her, because Ahmad (6707) and Abu Dawood (2276) narrated from ‘Abd-Allaah ibn ‘Amr that a woman said: “O Messenger of Allaah, my womb was a vessel for this son of mine and my breasts gave him (milk) to drink, and my lap was a refuge for him, but now his father has divorced me and he wants to take him away from me.” The Messenger of Allaah (peace and blessings of Allaah be upon him) said to her: “You have more right to him so long as you do not remarry.” This hadeeth was classed as hasan by al-Albaani in Saheeh Abi Dawood.
It is obligatory to allow the father to see his children and to ask how they are, whether they are in the custody of the mother or of someone else.
Because the mother’s right to custody is lost when she remarries, then it should be given to the one who is most entitled to that after her. There was some difference of opinion among the fuqaha’ as to who has more right after the mother. Some scholars said that the right passes to the mother’s mother. Shaykh al-Islam Ibn Taymiyah was of the view that the father has more right than the mother’s mother, on which basis custody should be given to you. Al-Sharh al-Mumti’, 6/26, complete edition).
Similarly if the mother’s mother is a kaafirah or an immoral person, then custody must be given to the father, even according to those who say that the mother’s mother has more right than the father.
It should be noted that what is meant by custody is keeping and raising the child. Hence a person’s right to custody is lost if he is immoral and corrupt, or careless and heedless, or if he travels a great deal which will harm his children’s interests.
The parents should cooperate in this matter, and pay attention to the child’s interests, so that their disputes will not adversely affect the children.
There is no Qur’aanic verse concerning this matter which specifies who is more entitled to custody, but the following verses should be sufficient for the Muslim:
“And whatsoever the Messenger (Muhammad) gives you, take it; and whatsoever he forbids you, abstain (from it). And fear Allaah; verily, Allaah is Severe in punishment”
“But no, by your Lord, they can have no Faith, until they make you (O Muhammad) judge in all disputes between them, and find in themselves no resistance against your decisions, and accept (them) with full submission”
“It is not for a believer, man or woman, when Allaah and His Messenger have decreed a matter that they should have any option in their decision. And whoever disobeys Allaah and His Messenger, he has indeed strayed into a plain error”
The Prophet (peace and blessings of Allaah be upon him) ruled that the mother loses the right to custody if she remarries, as stated in the hadeeth quoted above, so the believing woman has to accept that and submit.
And Allaah knows best.