intheheavensShaykhul Islaam, Imaam Ibn Taymiyyah (may Allaah have mercy on him), said,

The punishment for a sin committed by a believer is removed in ten ways:

1. He repents to Allaah (tawbah), so Allaah accepts his repentance, for the one who repents from sin is like the one who has no sin.

2. He seeks forgiveness from Allaah (istighfaar), so Allaah forgives him.

3. He does good deeds that erase his sin for good deeds erase bad ones.

4. His believing brethren pray for him or seek forgiveness for his sins during his life or death.

5. Or they [ask Allaah] to bestow on him, as a gift from them, their reward for their deed(s), with which Allaah benefits him by.

6. His Prophet Muhammad, sallAllaahu `alayhi wa sallam, intercedes for him.

7. Allaah tests him with trials in this world which expiate his sin.

8. Allaah tests him in al-Barzakh (the intermediate life in the grave, between the death and the Day of Judgment) which expiates his sin.

9. Allaah tests him in the various stages of the Day of Judgment which expiates his sins.

10. Or the Most Merciful of those who have mercy has mercy on him.

Whoever, then, is missed by these ten cannot blame anyone but himself.

Source: Majmoo` al-Fatawa 1:45, 7:487