It is narrated from both Sayyiduna Abu Sa'id al-Khudri and Sayyiduna Abu Hurayrah (may Allah be pleased with them both) that they said: We heard the Messenger of Allah (peace and blessings be upon him) saying: "No hardship, distress, illness or grief ever befalls a believer, not even a worry that troubles and grieves him, except that Allah, the Glorified, wipes away his sins in return for it."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 6537