Once, Amirul Mo’minin (as) was in the company of his companions when a person approached him and said: “O’ Amirul Mo’minin (as)! Purify me for I have committed sodomy with a boy.”
“Go home for you appear to have been affected by bile or melancholia,” advised the Imam (as).
The next day the person turned up again and confessed to his dirty act but the Imam (as) repeated what he had previously stated. The third day too he confessed and again Imam ‘Ali (as) repeated his earlier advice. When the man arrived on the fourth day and confessed to his crime, the Imam (as) said: “Now that you have confessed four times, choose one of the three punishments, which the Noble Prophet (S) has stipulated for this act – to be beheaded by means of a sword, to be hurled down from a height or to be burned with your hands and feet tied.”
“Which of these three punishments would be the severest for me?” the man asked.
“Burning by fire.”
“O’ ‘Ali! (as), I choose this punishment.”
The Imam (as) told him to prepare for it. The man got up, offered a two-rak’at prayer and supplicated: “O’ Lord! I have committed sin and You are aware of it. Fearing Your wrath, I have approached the successor and the cousin of the Noble Prophet (S) and have asked him to purify me of it. He asked me to choose one of the three punishments and I have chosen the most severe one. O’ Lord! I plead to You by Your mercy to make my burning in this world an expiation for my sin and not to burn me in the Hereafter!”
Having said this, he got up, began to weep and then hurled himself into the pit of roaring flames. The Imam (as) began to weep when he saw this and so did his companions; then he said in a loud voice: “O’ Man! Rise from within the fire for you have caused the angels to weep. Allah has accepted your repentance. Rise and henceforth do not conduct such an act!”
It is reported in another tradition that a person asked ‘Ali (as), “O’ Amirul Mo’minin (as)! Do you invalidate the punishment of Allah?”
Imam ‘Ali (as) replied, “Woe unto you! Whenever there exists an Imam appointed by Allah and a sinner repents for his sin, it is upon Allah to forgive him.”( Dastan-ha-e-Zindagi-e-’Ali (as), Page 51; Qadhawat-ha-e-Muhayyir al-’Uqul )