No, the young girl stays with her until seven years of age. The apparent implication of this is that it did not negate the custody of the girl due to her mother's marriage, while it did negate it for the boy. The basis for this is what was narrated: that Ali, Ja'far, and Zayd ibn Harithah disputed over the custody of the daughter of Hamzah. Ali said: 'She is my paternal cousin, and I took her.' Zayd said: 'She is my brother's daughter,' because the Messenger of Allah (peace be upon him) established a bond of brotherhood between Zayd and Hamzah. Ja'far said: 'She is my paternal cousin, and her maternal aunt is with me.' The Messenger of Allah (peace be upon him) said: 'The maternal aunt is like a mother,' and he handed her over to Ja'far. Abu Dawud narrated it with a similar meaning, and thus he granted her custody even though she was married. The first narration [that marriage negates custody] is the correct one. Ibn Abi Musa said: 'Action is taken upon it,' due to the saying of the Messenger of Allah (peace be upon him) to the woman: 'You are more entitled to him as long as you do not marry.' Furthermore, when she marries, she becomes occupied with the rights of the husband away from custody, so the father is more beneficial for the child, and because her benefits become owned by someone else, she is like a slave woman. As for the daughter of Hamzah, he only ruled in favor of her maternal aunt because her husband was one of those qualified for custody, and no one was equal to him in entitlement except for Ali, and Ja'far was favored because his wife was qualified for custody, so he was more appropriate. Based on this, whenever a woman is married to a man who is qualified for custody—such as a grandmother being married to a grandfather—her custody is not terminated because he shares with her in the birth and compassion for the child, so it is like the case of the mother if she is married to the father. If two paternal uncles dispute over custody, and one of them is married to the mother or the maternal aunt, he is more entitled due to the hadith of the daughter of Hamzah. Likewise, for any two agnates (asaba) who are equal, and one of them is married to someone who is qualified for custody, he is prioritized for that reason. The apparent view of al-Khiraqi is that marrying a stranger terminates custody merely by the contract, even if it is devoid of consummation. This is the view of al-Shafi'i. It is possible that it does not terminate except by consummation, which is the view of Malik, because by that she becomes occupied away from custody. The rationale for the first view is the saying of the Prophet (peace be upon him): 'You are more entitled to him as long as you do not marry,' and the marriage has occurred prior to consummation.
(1) In: Chapter of Who is Most Entitled to the Child, from the Book of Divorce. Sunan Abi Dawud, 1/530. It was also recorded by al-Bukhari, in: Chapter of How to Write: This is What So-and-so, Son of So-and-so, Has Agreed Upon..., from the Book of Reconciliation; and in: Chapter of the Umrah of al-Qada, from the Book of Military Expeditions (Maghazi). Sahih al-Bukhari, 3/242, 5/180. (2) Its takhrij (documentation) was previously mentioned on page 414.