The Talmud speaks of two levels of teshuvah: a level on which "one's willful sins are regarded as unintentional sins" and a higher level on which "one's willful sins are regarded as merits.
On the first level, a person's repentance achieves that his sins, even if done deliberately, should be regarded as no more than a mistake.
One of the explanations of this phenomenon is that when a person does teshuvah, he attains a higher level of awareness.
He now knows what he did not know previously.
So a deed that, relative to his prior state of mind might be considered willful, is a deed bereft of knowledge and understanding if measured against his current state of awareness.
Our sages say that, ''A person only sins when a spirit of insanity enters him."
The baal teshuvah ("penitent") is one who cures himself of this insanity, who now realizes that he performed his previous actions without a true understanding and awareness of their significance.
With such repentance, he severs himself from his past and attains new perspective on himself and his life, on his past and his future.
However, this level of teshuvah only transforms the person's status vis-à-vis his deed, from deliberate to unknowing, but not the significance of the deed itself.
The act remains wholly negative, an act of rebellion against God, an act of utterly profane kelipah.
The second level of teshuvah involves a much more radical change, for it transforms the very essence of the deed.
There is not merely a change of awareness regarding the sin but a transformation of the sin into a merit.
It is not only a change in the degree of the sin, from deliberate to something less than deliberate, but its complete reversal into a positive phenomenon.
To achieve this level of return or repentance, a person has to effect a change in his personal existence that is akin to the universal transformation in the end of days when "I will remove the spirit of profanity from the land."
He has to undergo a transformation so drastic that his entire being, and all his deeds and thoughts, acquire a new and different significance.
In effect, he passes into a new field of reality, where everything is completely different from what it was.
–Rabbi Adin Steinsaltz
From Opening the Tanya by Rabbi Adin Steinsaltz