Custody of children for a woman whose husband has died and she wants to re-marry
Question

What is the ruling concerning the children if the husband dies and the wife wants to live on her own, not with her in-laws. And in case she wanted to turn back to her home country. Do the in-laws have the right to take the responsibility for raising the children? Is the mother allowed to keep her children even if she may want to get married one day again?.
Praise be to Allah.Firstly: 
Custody of young children means looking after them, raising them, taking care of their interests and protecting them from that which may harm or upset them. 
The fuqaha’ are unanimously agreed that the mother is most entitled to custody of her children before they reach the age of discernment, if she and her husband get divorced or if he dies. 
In al-Mawsoo’ah al-Fiqhiyyah (17/301, 302) it says: 
Custody of children belongs to both parents, if they are married. If they separate, then custody belongs to the child’s mother, according to scholarly consensus, because of the report of a woman who came to the Messenger of Allah (peace and blessings of Allah be upon him) and said: O Messenger of Allah, this son of mine – my womb was a vessel for him, my lap was a haven for him and my breasts gave him milk, but his father says that he is going to take him away from me. He said: “You have more right to him so long as you do not get married.” End quote. 
With regard to custody, the best interests of the child must be taken into account. The one who is most entitled to custody may be an evildoer or unable to raise the child and look after his interests, or he may be heedless and neglect the child, in which case custody should be passed to the next person. Ibn al-Qayyim (may Allah have mercy on him) said: 
The hadith – i.e., the hadith “You have more right to him so long as you do not get married” – indicates that if the parents separate and they have a child, then the mother is more entitled to custody than the father, so long as there is nothing about the mother which would prevent her having precedence, or if the child is able to make the choice himself. This is something concerning which no difference of opinion is known. 
Zaad al-Mustaqni’ (5/435) 
Shaykh Muhammad ibn Saalih al-‘Uthaymeen (may Allah have mercy on him) said:  
It should be noted that with regard to this matter, attention must be paid to the child above all else. If going with one of them or staying with one of them will cause harm to his religious or worldly interests, then no approval should be given to one who will not protect him or take care of his interests, because the basic purpose of custody is to protect the child from that which will harm him, and to look after his interests. 
Al-Sharh al-Mumti’ (13/545). 
See also the answer to question no. 20473 . 
If the mother re-marries, she forfeits her right to custody of her children, according to scholarly consensus. 
This has been explained in the answer to question no. 20705. 
The scholars differed concerning the definition of the one to whom the right to custody is passed after the mother. The majority were of the view that it is passed to the mother’s mother, but Shaykh al-Islam Ibn Taymiyah and his student Ibn al-Qayyim (may Allah have mercy on them both) disagreed with them and said that it is passed to the father, but if they are both equal in terms of closeness to the child, then the relatives on the father’s side are given precedence, and the father’s mother is given precedence over the mother’s mother, and the paternal aunt is given precedence over the maternal aunt, and so on. 
He (may Allah have mercy on him) said: 
Unlike the small child, as the mother is better for him than the father, because women are kinder to small children, and have more experience in feeding them and carrying them, and are more patient in doing that, and are more compassionate towards them. So she is more able, more experienced, more compassionate and more patient in this regard, so the mother is singled out in sharee’ah with regard to custody of a child who has not reached the age of discernment. 
But there remains a point to be examined: did the Lawgiver single them out because the closeness of the mother takes precedence over the closeness of the father with regard to custody, or is it only because women are more able to achieve the purpose of custody than men? There are two scholarly views concerning this, and the issue has to do with which of two counterparts – such as the mother’s mother or the father’s mother, the half-sister on the mother’s side or the half-sister on the father’s side, the paternal aunt or the maternal aunt, and so on – has more right to custody. There are two opinions concerning this, both of which were narrated from Ahmad. The more correct of the two opinions is that the women on the father’s side are given precedence. This is what was mentioned by al-Kharaqi in his Mukhtasar concerning the paternal aunt and maternal aunt. Based on this, the father’s mother is given precedence over the mother’s mother, and the half-sister on the father’s side is given precedence over the half-sister on the mother’s side, and the paternal aunt is given precedence over the maternal aunt, as stated above. The father’s male relatives are given precedence over the mother’s relatives, and a half-brother on the father’s side has more right than a half-brother on the mother’s side, and the paternal uncle has more right than the maternal uncle. 
The Lawgiver did not give precedence to the mother’s relatives in any ruling, so the one who gives them precedence with regard to custody has gone against the basic rulings of sharee’ah. But giving precedence to the mother because she is a woman, and women are given precedence over men with regard to custody, this implies that the paternal grandmother is given precedence over the grandfather, just as the mother is given precedence over the father, and his sisters are given precedence over his brothers, and his paternal aunts over his paternal uncles, and his maternal aunts over his maternal uncles. This is the correct analogy and the sound view. But giving precedence to the mother’s female relatives over the father’s female relatives is contrary to the basic rulings and reason.  
Majmoo’ al-Fataawa (34/122, 123) 
With regard to your travelling with your children, in the answer to question no. 21612 it says that if they will not be harmed by that travelling, then you are still entitled to custody and it is not waived because of that travelling. 
To sum up the above: 
1.You have more right to your children than your husband’s family with regard to custody, care and raising them.
2.Your right to custody of your children is waived if you get married, and the children should move to be with their father’s mother. If that is not possible then they should go to their mother’s mother.
3.There is nothing wrong with your travelling with your children if this travel will not cause them any harm.
What we advise you to do is: 
Raise your children well and take good care of them; treat your husband’s family well and do not cut off ties with them or cut your children off from them. Think seriously about marrying, because it will keep you chaste and will not sever your ties with your children, and Allah may bless you with other good and righteous children. 
And Allah knows best.