Shaykh ul Islam Ibn Taymiyyah, may Allah have mercy on him, said:
The punishment for a sin committed by a believer is removed in ten ways:
1. He repents to Allah (taubah), so Allah accepts his repentance, for the one who repents from sin is like the one who has no sin.
2. He seeks forgiveness from Allah (istighfar), so Allah 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 Allah] to bestow on him as gift from the reward for their deeds, with which Allah benefits him.
6. His Prophet Muhammad, sallallahu `alayhi wa sallam, intercedes for him.
7. Allah tests him with trials in this world which expiate his sin.
8. Allah tests him in al-Barzakh (the intermediate life in the grave, between the death and the Day of Judgment) which expiates his sin.
9. Allah 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