"[And David and Solomon, when they gave judgment in the case of the field, when the sheep of the people wandered therein]" meaning: it fell into it. The 'nafsh' (wandering) is by night.
Al-Kalbi said: The owners of the field sought judgment against the owners of the sheep. David examined the value of the field, and it was close to the value of the sheep, so he judged that the sheep should be given to the owners of the field. They passed by Solomon, and he said: 'How did the Prophet of God judge among you?' They informed him, and he said to them: '[Excellent] was his judgment, yet there is that which would be gentler for both parties.' The owners of the sheep entered upon David and informed him, so he sent for Solomon. When he arrived before him, he said: 'What is this you said to me? How did you view the matter in which I judged?' He said: 'You should hand the sheep over to the owners of the field, so they may benefit from their milk, their clarified butter, and their wool for this year, while it is upon the owners of the sheep to cultivate for the owners of the field the same as what their sheep destroyed, and when...'
﴿وَدَاوُدَ وَسُلَيْمَانَ إِذْ يَحْكُمَانِ فِي الْحَرْث إِذْ نفشت فِيهِ﴾ أَيْ: وَقَعَتْ فِيهِ ﴿غَنَمُ الْقَوْمِ﴾ النَّفْشُ بِاللَّيْلِ.
قَالَ الْكَلْبِيُّ: إِنَّ أَصْحَابَ الْحَرْثِ اسْتَعَدَوْا عَلَى أَصْحَابِ الْغَنَمِ، فَنَظَرَ دَاوُدُ ثَمَنَ الْحَرْثِ، فَإِذَا هُوَ قَرِيبٌ مِنْ ثَمَنِ الْغَنَمِ، فَقَضَى بِالْغَنَمِ لِأَهْلِ الْحَرْثِ فَمَرُّوا بِسُلَيْمَانَ فَقَالَ: كَيْفَ قَضَى فِيكُمْ (نَبِيُّ اللَّهِ)؟ فَأَخْبَرُوهُ، قَالَ لَهُمْ: [نِعْمَ] مَا قَضَى، وَغَيْرُهُ كَانَ أَرْفَقُ بِالْفَرِيقَيْنِ كِلَيْهِمَا، فَدَخَلَ أَصْحَابُ الْغَنَمِ عَلَى دَاوُدَ؛ فَأَخْبَرُوهُ فَأَرْسَلَ إِلَى سُلَيْمَانَ، فَقَدِمَ عَلَيْهِ لَمَا حَدَّثْتَنِي كَيْفَ رَأَيْتَ فِيمَا قَضَيْتُ؟ قَالَ: تَدْفَعُ الْغَنَمَ إِلَى أَهْلِ الْحَرْثِ، فَيَنْتَفِعُونَ بِلَبَنِهَا وَسَمْنِهَا وَأَصْوَافِهَا عَامَهُمْ هَذَا، وَعَلَى أَهْلِ الْغَنَمِ أَنْ يَزْرَعُوا لِأَهْلِ الْحَرْثِ مِثْلَ الَّذِي أَفْسَدَتْ غَنَمُهُمْ فَإِذَا