It is narrated from Abu Hurayrah (may Allah be pleased with him) that a woman came to the Prophet (peace and blessings be upon him); she had been divorced, and her husband wanted to take the child from her. He (peace and blessings be upon him) said: "Cast lots." Her husband said: Who wants to come between me and my child? So he (peace and blessings be upon him) gave the child the choice, and he went with his mother.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النفقات / 15759