Sunan an-Nasa'i, Book 27, Hadith 100 (In-Book)

It was narrated that Zaid bin Arqam said: "Three men were brought to 'Ali while he was in Yemen; they all had intercourse with a woman during a single menstrual cycle. He asked two of them: 'Do you affirm that this child belongs to (the third man)?' And they said: 'No.' He asked another two of them: 'Do you affirm that this child belongs to (the third man)?' And they said: 'No.' So he cast lots between them, and attributed the child to the one whom the lot fell, and obliged him to pay two-thirds of the Diyah. The Prophet was told of this, and he laughed so much that his back teeth became visible."

أَخْبَرَنَا أَبُو عَاصِمٍ، خُشَيْشُ بْنُ أَصْرَمَ قَالَ أَنْبَأَنَا عَبْدُ الرَّزَّاقِ، قَالَ أَنْبَأَنَا الثَّوْرِيُّ، عَنْ صَالِحٍ الْهَمْدَانِيِّ، عَنِ الشَّعْبِيِّ، عَنْ عَبْدِ خَيْرٍ، عَنْ زَيْدِ بْنِ أَرْقَمَ، قَالَ أُتِيَ عَلِيٌّ رضى الله عنه بِثَلاَثَةٍ وَهُوَ بِالْيَمَنِ وَقَعُوا عَلَى امْرَأَةٍ فِي طُهْرٍ وَاحِدٍ فَسَأَلَ اثْنَيْنِ أَتُقِرَّانِ لِهَذَا بِالْوَلَدِ قَالاَ لاَ ‏.‏ ثُمَّ سَأَلَ اثْنَيْنِ أَتُقِرَّانِ لِهَذَا بِالْوَلَدِ قَالاَ لاَ ‏.‏ فَأَقْرَعَ بَيْنَهُمْ فَأَلْحَقَ الْوَلَدَ بِالَّذِي صَارَتْ عَلَيْهِ الْقُرْعَةُ وَجَعَلَ عَلَيْهِ ثُلُثَىِ الدِّيَةِ فَذُكِرَ ذَلِكَ لِلنَّبِيِّ صلى الله عليه وسلم فَضَحِكَ حَتَّى بَدَتْ نَوَاجِذُهُ ‏.‏

sunnah.com