كتاب أحاديث الأنبياء
Chapter: The Statement of Allah Taa'la: "And to Dawud, We gave Sulaiman (for a son). How excellent (a) slave he was ever oft-returning in repentance (to us)" (38.30)
بَابُ قَوْلِ اللَّهِ تَعَالَى: {وَوَهَبْنَا لِدَاوُدَ سُلَيْمَانَ نِعْمَ الْعَبْدُ إِنَّهُ أَوَّابٌ}
Sahih al-Bukhari 3426, 3427

Narrated Abu Huraira:

Allah's Messenger (ﷺ) said, "My example and the example o the people is like that of a person who lit a fire and let the moths, butterflies and these insects fall in it." He also said, "There were two women, each of whom had a child with her. A wolf came and took away the child of one of them, whereupon the other said, 'It has taken your child.' The first said, 'But it has taken your child.' So they both carried the case before David who judged that the living child be given to the elder lady. So both of them went to Solomon bin David and informed him (of the case). He said, 'Bring me a knife so as to cut the child into two pieces and distribute it between them.' The younger lady said, 'May Allah be merciful to you! Don't do that, for it is her (i.e. the other lady's) child.' So he gave the child to the younger lady."

حَدَّثَنَا أَبُو الْيَمَانِ، أَخْبَرَنَا شُعَيْبٌ، حَدَّثَنَا أَبُو الزِّنَادِ، عَنْ عَبْدِ الرَّحْمَنِ، حَدَّثَهُ أَنَّهُ، سَمِعَ أَبَا هُرَيْرَةَ ـ رضى الله عنه ـ أَنَّهُ سَمِعَ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ ‏"‏ مَثَلِي وَمَثَلُ النَّاسِ كَمَثَلِ رَجُلٍ اسْتَوْقَدَ نَارًا، فَجَعَلَ الْفَرَاشُ وَهَذِهِ الدَّوَابُّ تَقَعُ فِي النَّارِ ‏"‏‏.‏ وَقَالَ ‏"‏ كَانَتِ امْرَأَتَانِ مَعَهُمَا ابْنَاهُمَا جَاءَ الذِّئْبُ فَذَهَبَ بِابْنِ إِحْدَاهُمَا، فَقَالَتْ صَاحِبَتُهَا إِنَّمَا ذَهَبَ بِابْنِكِ‏.‏ وَقَالَتِ الأُخْرَى إِنَّمَا ذَهَبَ بِابْنِكِ‏.‏ فَتَحَاكَمَتَا إِلَى دَاوُدَ، فَقَضَى بِهِ لِلْكُبْرَى فَخَرَجَتَا عَلَى سُلَيْمَانَ بْنِ دَاوُدَ فَأَخْبَرَتَاهُ‏.‏ فَقَالَ ائْتُونِي بِالسِّكِّينِ أَشُقُّهُ بَيْنَهُمَا‏.‏ فَقَالَتِ الصُّغْرَى لاَ تَفْعَلْ يَرْحَمُكَ اللَّهُ، هُوَ ابْنُهَا‏.‏ فَقَضَى بِهِ لِلصُّغْرَى ‏"‏‏.‏ قَالَ أَبُو هُرَيْرَةَ وَاللَّهِ إِنْ سَمِعْتُ بِالسِّكِّينِ إِلاَّ يَوْمَئِذٍ، وَمَا كُنَّا نَقُولُ إِلاَّ الْمُدْيَةُ‏.‏
Reference : Sahih al-Bukhari 3426, 3427
In-book reference : Book 60, Hadith 98
USC-MSA web (English) reference : Vol. 4, Book 55, Hadith 637
  (deprecated numbering scheme)