The Baal Hatanya is an excellent source on this issue of purity of thought. "It’s no disgrace," he writes, "to have such thoughts pushing their way in and trying to steal the limelight." On the contrary, it’s an opportunity granted us to firmly eject them, thereby avoiding the Torah prohibition (Bamidbar 15:39), "Do not stray after your heart and your eyes."
"Not every mitzvah calls for an action. Here is a case of a passive mitzvah, and every time we try to switch to a more kosher line of thought it earns us rewards equal to a mitzvas a’sei. When we refuse to yield to unwanted images tugging at our mind’s eye, we have reason to feel elevated and even joyous, equal to the simcha shel mitzvah when performing the mitzvah of succah and lulav. But, you protest, how can I rejoice considering how low I must be if such dishonourable thoughts keep entering my mind?"
Here the Baal Hatanya (Lekutei Amorim ch. 23 and 28), with one stroke of his masterful pen, swings our mood around one hundred and eighty degrees. He makes us feel not battered but flattered. He tells of how there are two types of nachas ruach (delight) before Hashem. The first type is that of the extremely righteous who vanquish the evil elements inside them forever. The second type is the average man who constantly battles against the appealing impurities all around. His task is to keep on shoving away impure thoughts coming from the heart and proceeding towards the mind. This causes tremendous effects in the heavenly realms.
Shall we try to imagine what transpires in shamayim when a Yid finds unholy thoughts and sensations rising inside him and dutifully quells them at once? The words of the Zohar (Parshas Terumah) give us a keyhole glimpse which reveals how the sitra achra (source of all evil) is firmly settled on his perch like a mighty eagle - a bleak prospect indeed. Who is able to unseat this towering menace?
Suddenly, an act performed on earth is reported: A malach announces, "So-and-so has just controlled his thoughts and quietly denied himself a ‘minor’ indulgence. In defiance of today’s decidedly casual, fun-loving society, he chose to crown Hashem as Melech over himself - his body and his soul!"
Immediately, the sitra achra’s power is weakened, for we have a principle that overcoming our sitra achra in This World correspondingly unseats the mighty sitra achra in the upper spiritual worlds. He is demoted and a sublime light spreads all across the heavens. The light of this one "small" deed radiates up to the furthermost celestial spheres.
As for our unsung hero below, Chazal (Yuma 39a) promised that a person need only sanctify himself a little and Shamayim will pour sanctity upon him in abundance.