Praise be to Allaah.
Giving voluntary charity is a confirmed Sunnah at all times, as is indicated by the Qurâaan and Sunnah and the consensus of the scholars. It says in Kashshaaf al-Qinaaâ (2/295): Voluntary charity is mustahabb at all times according to consensus, because Allah, may He be exalted, enjoined it and encouraged itâ¦ End quote. See also the answer to question no. 36783.
What is required of the Muslim if he commits a sin is to repent to Allah from it immediately, because Allah, may He be exalted, says (interpretation of the meaning):
âAnd all of you beg Allaah to forgive you all, O believers, that you may be successfulâ
And His Messenger (blessings and peace of Allah be upon him) instructed us to repent, as he said: âO people, repent to Allaah, for I repent to Allaah one hundred times a day.â Narrated by Muslim (2702). See also the answer to question no. 129479.
If the sin had to do with the rights of another person, such as stealing or usurping property, the right must be restored to the one to whom it belongs, or his pardon and forgiveness should be sought. For more information on the other conditions of sincere repentance, please see the answer to question no. 104241.
There is nothing wrong with the Muslim giving some of his wealth in charity after every sin he commits, because of the general meaning of the verses in which Allah says (interpretation of the meaning):
âVerily, the good deeds remove the evil deedsâ
âIf you disclose your Sadaqaat (almsgiving), it is well; but if you conceal them and give them to the poor, that is better for you. (Allaah) will expiate you some of your sins. And Allaah is Well-Acquainted with what you doâ
Ibn Jareer said: âwill expiate you some of your sinsâ means: Allah will expiate your sins by virtue of your charity. End quote.
It was narrated that Abu Dharr (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said to me: âFear Allah wherever you are, and follow up a bad deed with a good deed, it will wipe it out.â Narrated by al-Tirmidhi (1987); classed as hasan by al-Albaani in Sunan al-Tirmidhi. And it was narrated that Kaâb ibn âAjrah (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said to me: âCharity extinguishes sin as water extinguishes fire.â Al-Tirmidhi (614); classed as saheeh by al-Albaani in Sunan al-Tirmidhi.
It is proven in the story about Kaâb ibn Maalik (may Allah be pleased with him), when he stayed behind from the campaign to Tabook, that he said: O Messenger of Allaah, as part of my repentance, I will give up my wealth as charity to Allaah and His Messenger (blessings and peace of Allah be upon him). The Messenger of Allaah (blessings and peace of Allah be upon him) said: âKeep some of your wealth; that is better for you.â
Narrated by al-Bukhaari (2758) and Muslim (2769).
Al-Nawawi (may Allah have mercy on him) said: This indicates that it is mustahabb to give charity in gratitude to Allah for ongoing blessings, especially great blessings.
End quote from Sharh Saheeh Muslim
In Mughni al-Muhtaaj (3/206) it says: It is recommended to give charity after every sin; this was stated by al-Jarjaani. End quote.
And Allah knows best.