The Messenger of Allah ﷺ said, "While a man was walking along a road, he became severely thirsty. He found a well, climbed down into it, drank, and then came out. There he saw a dog panting and licking the moist earth out of thirst. The man said to himself, 'This dog has reached the same state of thirst that I had reached.' So he went back down into the well, filled his leather sock with water, held it in his mouth as he climbed up, and gave the dog a drink. Allah was grateful to him for that and forgave him."The companions asked, "Messenger of Allah, do we receive a reward even for treating animals kindly?"He replied, "There is a reward for showing kindness to every living creature."
أن رسول الله ﷺ قال: بينما رجل يمشي بطريق إذ اشتد عليه العطش، فوجد بئرا فنزل فيها فشرب، ثم خرج، فإذا كلب يلهث يأكل الثرى من العطش، فقال الرجل: لقد بلغ هذا الكلب من العطش مثل الذي بلغ مني، فنزل البئر فملأ خفه ماء، ثم أمسكه بفيه حتى رقي، فسقى الكلب فشكر الله له فغفر له. قالوا: يا رسول الله، وإن لنا في البهائم لأجرا؟ فقال: في كل ذات كبد رطبة أجر
Malik reported it in the chapter on the description of the Prophet ﷺ (23) from Sumayy, from Abu Salih Samman, from Abu Hurairah, and he related it. Bukhari reported it in the chapter on irrigation (2363) and Muslim in the book of greetings (2244-153), both of them through Malik bin Anas with the same chain.