Right to custody
Question

I have been married to my wife for more than four years and she lives with her family because of my studies, and Allah has blessed me with three daughters. I am having a dispute with my wife because during the first year of marriage I caught my wife speaking to a stranger on the phone. But we put an end to the matter on the basis that this man had no relationship with her but he had been annoying her and she was afraid that I would find out and think badly of her. But I could not forget the matter and the issue haunted me at that time. I got married whilst I was abroad in an ‘urfi marriage after which my first wife contracted a venereal disease that affects women, so I decided to divorce the second wife because I saw the good attitude of my first wife. Please note that the second wife was living in her own country outside of the Kingdom; I used to see her infrequently and the ‘urfi marriage contract was not documented in court. I tore up the paper that we had and I ended the relationship with her. I also used to drink beer that contains alcohol; I used to drink it when I travelled abroad. Then years passed and Allah guided me and in a moment of sincerity before Allah I decided to give up sin. I told my wife voluntarily about the second wife and that I drank beer, but I had repented to Allah and I was determined to become steadfast, but my wife could not stand it and now she is insisting on divorce, even though I do not want that. But all my efforts have ended in failure. Do I have the right to keep her on an honourable basis as Allah loves and is pleased with? Does she have the right to ask for khula’ from me if medical reports prove that she was harmed because of the second wife? What about the three daughters in the event of a divorce, Allah forbid? Their ages are six months, three years and four years. Do I have the right to custody of them, and when? Because I am determined to raise them, in sha Allah, as Allah likes and is pleased with.
Praise be to Allah.Firstly: 
We praise Allah for having enabled you to repent and guided you, and diverted evil from you, and we ask Him to grant you more and make you steadfast. 
Secondly: 
You should choose a righteous person from among your family or your wife’s family to try to bring about a reconciliation between you, and to convince your wife to give up the idea of seeking a divorce, for the sake of her home and her daughters. 
You have the right to keep her and to refuse to divorce her, and to tell her that you want to continue to live together. 
The wife does not have the right to ask for a divorce or khula’ unless there is a reason for that, such as if she has been harmed, because the Prophet (peace and blessings of Allah be upon him) said: “Any woman who asks her husband for a divorce when it is not absolutely necessary, the fragrance of Paradise will be forbidden to her.” Narrated by Abu Dawood (2226), al-Tirmidhi (1187) and Ibn Majaah (2055); classed as saheeh by al-Albani in Saheeh Abi Dawood. 
But if the qaadi rules that there should be a divorce or khula’, this depends on what reasons the wife has given. 
Thirdly: 
In the event of divorce, the mother retains custody of the children until they are seven years old, so long as she does not marry again, because of the report narrated by Ahmad (6707) and Abu Dawood (2276) from ‘Abd-Allah ibn ‘Amr (may Allah be pleased with him), that 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 he rested in my lap. But his father has divorced me and wants to take him 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 get married again.” Classed as saheeh by al-Albani in Saheeh Abi Dawood. 
When the child reaches the age of seven, if male he should be given the choice between his parents and he should live with the one who is dearest to him. With regard to a female, there is a difference of opinion among the scholars: 
Al-Shaafa’i said: She should also be given the choice. 
Abu Haneefah said: The mother has more right to her, until she gets married or menstruates. 
Maalik said: The mother has more right to her until she gets married and her husband consummates the marriage with her. 
Ahmad said: The father has more right to her because the father is the best one to look after her. 
See: al-Mawsoo’ah al-Fiqhiyyah (17/314-317). 
In view of these differences and the fact that there is no decisive text about this in the Sunnah, the matter should be referred to a shar’i qaadi (judge) to determine who the daughter should live with when she reaches the age of seven. 
We ask Allah to set our affairs and those of all the Muslims straight. 
And Allah knows best.