The Messenger of Allah ﷺ said, "There were two women, each with her son. A wolf came and carried off the son of one of them.She said to her companion, 'It was your son he took.'The other replied, 'No, it was your son he took.'So they brought their dispute before Dawud , who ruled that the child belonged to the elder woman.Then they went out to Sulayman bin Dawud, peace be upon them both, and informed him of the matter.He said, 'Bring me a knife so I may cut him in half between them.'The younger woman cried out, 'Do not do it, may Allah have mercy on you. He is her son.'So he ruled that the child belonged to the younger woman."
أن رسول الله ﷺ قال: كانت امرأتان معهما ابناهما، جاء الذئب فذهب بابن إحداهما، فقالت لصاحبتها: إنما ذهب بابنك، وقالت الأخرى: إنما ذهب بابنك، فتحاكما إلى داود عليه السلام، فقضى به للكبرى، فخرجتا على سليمان بن داود عليهما السلام، فأخبرتاه، فقال: ائتوني بالسكين أشقه بينهما، فقالت الصغرى: لا تفعل يرحمك الله هو ابنها، فقضى به للصغرى.
Bukhari narrated it in the Book of Legal Punishments (6769), and Muslim in the Book of Judgments (1720), both from the hadith of Abu Zinad, from Araj, from Abu Hurairah, and he mentioned it. Ibn Jawzi said, "Sulayman deduced a ruling when he saw that the matter admitted of more than one possibility, and he did well, and both of them ruled by ijtihad, because if Dawud had ruled by an explicit text, it would not have been permissible for Sulayman to rule against it." Fath al-Bari (6/465)