The Messenger of Allah ﷺ took from us the same pledge he took from the women, that we would not associate anything with Allah, nor steal, nor commit adultery, nor kill our children, nor slander one another. Whoever among you fulfills this, his reward is with Allah. Whoever commits any offense and has the prescribed punishment carried out on him, that serves as his expiation. And whoever has his sin concealed by Allah, his affair rests with Allah. If He wills, He will punish him, and if He wills, He will forgive him.
أخذ علينا رسول الله ﷺ كما أخذ على النساء: أن لا نشرك بالله شيئا، ولا نسرق، ولا نزني، ولا نقتل أولادنا، ولا يعضه بعضنا بعضا. فمن وفى منكم فأجره على الله، ومن أتى منكم حدا فأقيم عليه فهو كفارته، ومن ستره الله عليه فأمره إلى الله، إن شاء عذبه وإن شاء غفر له.
Muslim narrated it in the Book of Hudud (43/1709), from Ismail bin Salim, who reported, "Hushaym informed us, Khalid informed us, from Abu Qilaba, from Abu Ashath Sanani, from Ubadah," and he related it.His saying, "and does not slander him," means he does not accuse him of a false charge, which is a lie. This qualification clarifies the intent of the hadith, showing that it does not include shirk against Allah, which was mentioned at the beginning of the hadith, because Allah said, "Indeed, Allah does not forgive that partners be associated with Him" [Nisa 4:48]. Shirk is not subject to His will in that sense. So if a Muslim apostatizes and becomes a polytheist, and is killed for his apostasy, that killing does not serve as atonement for him. Rather, this applies specifically to the Muslim who commits an offense warranting a legal punishment, such as fornication, theft, false accusation, drinking, and the like.Shafii said, "I have not heard anything in this matter better than this hadith regarding the idea that the legal punishment serves as atonement for the one who bears it." He also said, "I love that whoever commits a sin, which Allah then conceals for him, should conceal it for himself, and repent between himself and his Lord." Tirmidhi mentioned this (1439).