The Father Doesn't Spend on Children; Does He Get Custody in Islam?
Question

My question is about custody of children. I know that if a couple gets divorced, then the mother has more right to the children who have not yet reached the age of independence, but if she remarries then the father has more right. My question is if the father of the children does not fulfil his financial responsibility towards the children, does he still have the right to take them away from the mother? In the particular situation I am speaking of, the man has demonstrated that he is able to provide, because he has remarried and has had a child and is supporting that child, but he is not supporting his two children from the previous marriage. He tells their mother that if she marries again he will take the children, is this right?
Praise be to Allah.Who has more right to custody in Islam?
One of the matters on which there is scholarly consensus is that the woman is more entitled to custody of the child so long as he has not reached the age of discernment, as the child at that stage needs the kind of compassion and care that only women can give. But this right is forfeited if the woman remarries , because she will be distracted by her new husband from taking care of her child, and because there is a conflict of interest between the child and the new husband. 
Ibn Al-Mundhir (may Allah have mercy on him) narrated that there was scholarly consensus that the mother’s right to custody is forfeited if she remarries . (See: Al-Kafi by Ibn ‘Abd Al-Barr, 1/296; Al-Mughni, 8/194) 
This is indicated by the Hadith of `Abdullah ibn `Amr (may Allah be pleased with him) according to whom a woman said: O Messenger of Allah, my womb was a vessel for this son of mine, and my breasts gave him to drink, and my lap was a refuge for him, but his father has divorced me and he wants to take him away from me. The Messenger of Allah (peace and blessings of Allah be upon him) said to her: “You have more right to him so long as you do not remarry.” (Narrated by Ahmad (6707) and Abu Dawud (2276); classed as sound by Al-Albani in Sahih Abu Dawud, and classed as sound by Ibn Katheer in Irshad Al-Faqih (2/250))
Is maintenance of children obligatory upon the father?
Maintenance of children is obligatory upon the father according to scholarly consensus, whether he keeps his wife or divorces her, and whether the wife is poor or rich. So she is not obliged to spend on the children if the father is around. 
If the children are in the custody of a divorced woman , then their father must support them, and the mother who has custody of a child who is still breastfeeding has the right to ask for payment for nursing the child. 
Maintenance of children includes accommodation, food, drink, clothing and education, and everything that the child needs, and is to be based on what is reasonable, paying attention to the husband’s situation, because Allah says (interpretation of the meaning): 
“Let the rich man spend according to his means; and the man whose resources are restricted, let him spend according to what Allah has given him. Allah puts no burden on any person beyond what He has given him. Allah will grant after hardship, ease.” [Al-Talaq 65:7]
This varies from one country to another and from one person to another. 
If the husband is rich then he must spend according to his wealth, and if he is poor or of moderate means, then he must also spend according to his means. If the parents agree upon a specific amount of money, whether it is large or small, then that is up to them. But in the case of a dispute, the one who decides about that is the judge. 
It is permissible for a divorced woman to ask her ex-husband for payment for breastfeeding the child , according to scholarly consensus. 
Ibn Qudamah (may Allah have mercy on him) said in Al-Mughni: 
“(The expenses for) breastfeeding the child are to be borne by the father only, and he has no right to force the mother to breastfeed the child if she is divorced, and we know of no difference of opinion concerning that." (Al-Mughni  11/430).
He also said: “If the mother asks for payment at the usual rate for breastfeeding, she is more entitled to that, whether the father finds someone else to breastfeed him for free or not. " (Al-Mughni  11/431) 
Shaykh Al-Islam Ibn Taymiyyah (may Allah have mercy on him) said: 
“With regard to payment for breastfeeding, she is entitled to that according to scholarly consensus, as Allah says (interpretation of the meaning): 
“And if they breastfeed for you (nurse your child), then give them their payment.” [Al-Talaq 65:6]." (Al-Fatawa Al-Kubra  3/347) 
If the father doesn't spend on his children, is he entitled to custody in Islam?
With regard to custody – as defined by a number of scholars – it means taking care of the one who has not reached the age of discernment and cannot live independently, raising him in accordance with his best interests, and protecting him from anything that may harm him. (Rawdat Al-Talibin, 9/98) 
This means, taking care of the small child and looking after him. So the main issue of custody is taking care of the interests of the child. Hence if the father refuses to undertake this duty towards the child, which includes maintenance, then he is sinning, and forfeits his right to custody .
It says in Ar-Rawd Al-Murbi`: “The child should not stay with one who does not protect him and take care of him, because that is contrary to the purpose of custody." (Al-Rawd Al-Murbi’  3/251)
Ibn Qudamah Al-Maqdisi (may Allah have mercy on him) said: “Custody is aimed at looking after the child, so it should not be given in a way that will be detrimental to his welfare and his religious commitment." (Al-Mughni  8/190)  
Ibn Al-Qayyim (may Allah have mercy on him) said: 
“If we give precedence to one of the parents, we must pay attention to how he looks after the child. Hence Malik and Al-Layth said: If the mother is not in a safe place or she is not of good character, then the father has the right to take the child from her. Similarly, in the well known report from him, Imam Ahmad said that it depends on his ability to take care of the child. If he is careless or unable to do that, or is not of good character, or he is immoral and the mother is different from him, then she undoubtedly has more right to take the daughter. Our Shaykh said: If one of the parents fails to educate the boy and raise him in accordance with Islamic teachings, then he is sinning and has no guardianship over him. Anyone who does not do his duties as a guardian has no guardianship. He should either be dismissed as the guardian and replaced by someone who will do what is required, or someone else should be appointed with him who will do what is required along with him, because the aim is to obey Allah and His Messenger according to one’s ability … If the father marries a woman who does not take care of his daughter, and her mother is better able to take care of her than this co-wife, then custody should definitely be given to the mother ." (Zad Al-Ma`ad  5/424) 
Shaykh `Abd Ar-Rahman As-Sa`di said: 
“If one of them neglects their duties with regard to custody and care of the child, then he forfeits his guardianship and the other should be appointed instead." (Al-Fatawa As-Sa`diyyah  p. 535)
Based on this, if the father refuses to spend on his children’s maintenance, he forfeits the right to custody, even if his refusal is aimed at hurting the mother. This indicates that he is not to be trusted to take care of his children’s interests. The mother has the right to ask him in court for maintenance of his children. 
And Allah knows best.