Haram bin Muhayyisah al-Ansari narrates that al-Bara' bin Azib had a she-camel that was given to straying into crops. It entered an orchard and damaged it. The Messenger of Allah (peace and blessings be upon him) was spoken to about it, and he ruled that guarding orchards by day is the responsibility of their owners, that guarding livestock at night is the responsibility of their owners, and that the owners of livestock are liable for whatever their livestock damage at night.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الأشربة والحد فيها / 17676