[Machine] In His statement, "And (mention) David and Solomon, when they judged concerning the field – when the sheep of a people overran it [at night], and We were witnesses to their judgement. And We gave understanding of the case to Solomon, and to each (of them) We gave judgement and knowledge." (Quran 21: 79), it is narrated from Masrooq and Mujahid the meaning of this (verse). And Allah (swt) returned the judgement in this incident and similar incidents to what the Messenger of Allah ﷺ ruled in the case of the camel of Bara' ibn Azib when it entered the farmland of some of the Ansar and caused damage. He ruled that during the day, the owners are responsible for safeguarding their wealth, and during the night, the owners of the livestock are responsible for any damage caused by the livestock. Ash-Shafi'i said, al-Hasan ibn Abi al-Hasan said, "If it were not for this verse, I would have thought that the judges have perished. However, Allah praised this (judgement) for its correctness and commended it for its effort."
فِي قَوْلِهِ ﷻ {وَدَاوُدَ وَسُلَيْمَانَ إِذْ يَحْكُمَانِ فِي الْحَرْثِ إِذْ نَفَشَتْ فِيهِ غَنْمُ الْقَوْمِ} قَالَ كَرْمٌ وَقَدْ أَنْبَتَتْ عَنَاقِيدُهُ فَأَفْسَدَتْهُ قَالَ فَقَضَى دَاوُدُ عَلَيْهِ السَّلَامُ بِالْغَنَمِ لِصَاحِبِ الْكَرْمِ فَقَالَ سُلَيْمَانُ غَيْرَ هَذَا يَا نَبِيَّ اللهِ ﷺ قَالَ وَمَا ذَاكَ؟ قَالَ تَدْفَعُ الْكَرْمَ إِلَى صَاحِبِ الْغَنَمِ فَيَقُومُ عَلَيْهِ حَتَّى يَعُودَ كَمَا كَانَ وَتَدْفَعُ الْغَنَمَ إِلَى صَاحِبِ الْكَرْمِ فَيُصِيبُ مِنْهَا حَتَّى إِذَا كَانَ الْكَرْمُ كَمَا كَانَ دَفَعْتَ الْكَرْمَ إِلَى صَاحِبِهِ وَدَفَعْتَ الْغَنَمَ إِلَى صَاحِبِهَا قَالَ اللهُ ﷻ {فَفَهَّمْنَاهَا سُلَيْمَانَ وَكُلًّا آتَيْنَا حُكْمًا وَعِلْمًا} [الأنبياء 79] وَرُوِّينَا عَنْ مَسْرُوقٍ وَمُجَاهِدٍ مَعْنَى هَذَا وَقَدْ رَدَّ اللهُ تَعَالَى الْحُكْمَ فِي هَذِهِ الْحَادَثةِ وَأَشْبَاهِهَا إِلَى مَا حَكَمَ بِهِ رَسُولُ اللهِ ﷺ فِي نَاقَةِ الْبَرَاءِ بْنِ عَازِبٍ حِينَ دَخَلَتْ حَائِطًا لِقَوْمٍ مِنَ الْأَنْصَارِ فَأَفْسَدَتْ فَقَضَى أَنَّ حِفْظَ الْأَمْوَالِ عَلَى أَهْلِهَا بِالنَّهَارِ وَعَلَى أَهْلِ الْمَوَاشِي مَا أَفْسَدَتِ الْمَوَاشِي بِاللَّيْلِ قَالَ الشَّافِعِيُّ قَالَ الْحَسَنُ بْنُ أَبِي الْحَسَنِ لَوْلَا هَذِهِ الْآيَةُ لَرَأَيْتُ أَنَّ الْحُكَّامَ قَدْ هَلَكُوا وَلَكِنَّ اللهَ حَمِدَ هَذَا بِصَوَابِهِ وَأَثْنَى عَلَى هَذَا بِاجْتِهَادِهِ