Jami` at-Tirmidhi, Book 10, Hadith 109 (Tirmidhi 1075)

Abdullah narrated that:

The Prophet said: "Whoever consoles a person with an affliction, then he gets the same reward as him."