The Messenger of Allah ﷺ said, "While a man was walking along a road, he became overcome with thirst. He found a well, descended 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 out, and gave the dog a drink. Allah was grateful to him for that and forgave him."The companions asked, "Messenger of Allah, do we have a reward for what we do for animals?"He replied, "There is a reward in caring for every living creature with a moist liver."
حدثنا عبد الله بن مسلمة القعنبي عن مالك عن سمي مولى أبي بكر عن أبي صالح السمان
أن رسول الله ﷺ قال بينما رجل يمشي بطريق فاشتد عليه العطش فوجد بئرا فنزل فيها فشرب ثم خرج فإذا كلب يلهث يأكل الثرى من العطش فقال الرجل لقد بلغ هذا الكلب من العطش مثل الذي كان بلغني فنزل البئر فملأ خفه فأمسكه بفيه حتى رقي فسقى الكلب فشكر الله له فغفر له فقالوا يا رسول الله وإن لنا في البهائم لأجرا فقال في كل ذات كبد رطبة أجر
Sourced from Bukhari, Musaqat, chapter on the merit of giving water to drink, hadith no. 2363, and Muslim, Salam, chapter on the merit of giving water and food to animals worthy of respect, hadith no. 2244, from the hadith of Malik through the same chain, and it is found in Muwatta (Yahya).