Ibn Jurayj says that Hilal bin Usamah told him that Abu Maymunah Sulaym, a mawla from the people of Madinah and a truthful man, said: I was sitting with Sayyiduna Abu Hurayrah (may Allah be pleased with him) when a Persian woman came with her son; she had been divorced. She began to say in Persian: O Abu Hurayrah (may Allah be pleased with him)! My husband wants to take my child from me. Sayyiduna Abu Hurayrah (may Allah be pleased with him) said: Cast lots for him. Meanwhile her husband also came and said: Who wants to keep my child from me? Sayyiduna Abu Hurayrah (may Allah be pleased with him) said: I did not say this on my own account; rather, I was sitting with the Prophet (peace and blessings be upon him) when a woman came and said: "O Messenger of Allah (peace and blessings be upon him)! My husband wants to take my child back from me, though he (my son) draws water for me from the well of Abu Inabah and has been of benefit to me." He (peace and blessings be upon him) decided between them by casting lots. Then the boy's father said: Who will keep my child from me? So he (peace and blessings be upon him) addressed the child and said: "This is your father and this is your mother; go with whichever of them you wish." The child took hold of his mother's hand, and she took him away.
These are the words of al-Rudhbari; the hadith of Ibn Bishran has fewer words, but the meaning is the same.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النفقات / 15758