It is narrated from Sayyiduna Khuzaymah bin Thabit (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Any servant who does something that Allah has forbidden, and then its prescribed punishment (hadd) is carried out on him, that becomes an expiation for that sin of his."
Hadith Referenceالمعجم الكبير للطبراني / باب الخاء / 3716