during the daytime, unless its owner lets it loose close to something it is accustomed to damaging.
Imam al-Baghawī (may Allah have mercy on him) said: “The scholars hold that whatever damage free-roaming livestock causes to another’s property in the daytime entails no liability for the owner, whereas damage done at night is his responsibility. Custom dictates that the owners of orchards and gardens guard them by day, while livestock owners watch their animals by night. Whoever departs from this convention acts against accepted practice. This ruling applies when the animal’s owner is not with it; if he is present, he must pay for whatever it destroys.”
Allah has mentioned the story of David and Solomon and their ruling on this matter: “And [remember] David and Solomon, when they judged concerning a field into which the sheep of some people had strayed at night, and We were witnesses to their judgment. We gave Solomon understanding of it, and to each of them We granted wisdom and knowledge” (Qur’an 21:78–79).
Shaykh al-Islām Ibn Taymiyyah (may Allah have mercy on him) said: “The Qur’an explicitly praises Solomon for being granted insight into ‘compensation in kind.’ The term nafsh refers to sheep grazing at night, and the incident occurred in a vineyard. David ruled for payment of the value of the loss: he appraised the flock, found its worth equal to the damage, and handed the sheep over to the owners of the field. Solomon, however, ruled that the sheep owners must make good the loss in kind by restoring the vineyard until it returned to its former state. He did not deprive them of profit during the period from destruction to restoration; rather, he gave the vineyard owners those same sheep so that they could benefit from their offspring in proportion to the vineyard’s expected yield, thereby recouping from the flock’s increase what they had missed from their crop. In doing so, he took both forms of liability into consideration.