Abu Huraira reported: The Messenger of Allah, peace and blessings be upon him, said:
بَيْنَمَا رَجُلٌ يَمْشِي بِطَرِيقٍ اشْتَدَّ عَلَيْهِ الْعَطَشُ فَوَجَدَ بِئْرًا فَنَزَلَ فِيهَا فَشَرِبَ ثُمَّ خَرَجَ فَإِذَا كَلْبٌ يَلْهَثُ يَأْكُلُ الثَّرَى مِنْ الْعَطَشِ فَقَالَ الرَّجُلُ لَقَدْ بَلَغَ هَذَا الْكَلْبَ مِنْ الْعَطَشِ مِثْلُ الَّذِي كَانَ بَلَغَ مِنِّي فَنَزَلَ الْبِئْرَ فَمَلَأَ خُفَّهُ مَاءً ثُمَّ أَمْسَكَهُ بِفِيهِ حَتَّى رَقِيَ فَسَقَى الْكَلْبَ فَشَكَرَ اللَّهُ لَهُ فَغَفَرَ لَهُ
Once a man suffered from thirst while he was walking on a journey. When he found a well, he climbed down into it and drank from it. Then he came out and saw a dog lolling its tongue from thirst and licking the ground. The man said: This dog has suffered thirst just as I have suffered from it. He climbed down into the well, filled his shoe with water, and caught it in his mouth as he climbed up. Then he gave the dog a drink. Allah appreciated this deed, so He forgave him.
It was said, “O Messenger of Allah, is there a reward for charity even for the animals?” The Prophet said:
فِي كُلِّ كَبِدٍ رَطْبَةٍ أَجْرٌ
In every living being there is a reward for charity.
Source: Sahih Muslim 2244, Grade: Sahih