Amr bin Shuaib on his father's authority said that his grandfather (Abdullah ibn Amr ibn al-As) reported: A woman said: Messenger of Allah, my womb is a vessel to this son of mine, my breasts, a water-skin for him, and my lap a guard for him, yet his father has divorced me, and wants to take him away from me. The Messenger of Allah ﷺ said: You have more right to him as long as you do not marry.
Related hadith on this topic
Explanation & Benefits
Shaykh Umar Farooq Saeedi
Benefits and Issues:
This is an authentic proof that the mother is more entitled to the child than the father as long as she does not remarry, and even after marriage, if the husband is agreeable, she may keep the child with her.
But if he is not agreeable, then the child will be given to the father.
Source: Sunan Abu Dawood – Commentary by Shaykh Umar Farooq Saeedi, Page: 2276