What should you do when unwanted thoughts invade your mind—not during prayer, but during ordinary life?
The Tanya's twenty-seventh chapter offers counterintuitive advice: be happy about it.
Rabbi Schneur Zalman addresses the person who is going about daily business when lustful or impure thoughts suddenly appear. The natural reaction is shame and distress. But the Tanya says: if you turn your mind away from these thoughts, you are fulfilling the commandment in (Numbers 15:39): "You shall not follow after your heart and after your eyes by which you go astray." This verse does not speak to the tzaddik (a righteous person), who does not have such thoughts. It speaks to the benoni—the ordinary person whose mind is a contested battleground.
Every time you refuse to follow a lustful thought, the Talmud teaches in Tractate Kiddushin, you receive reward as if you had performed a positive commandment. The refusal itself is the mitzvah. So instead of being sad about the intrusion, be glad about the refusal.
The Tanya then diagnoses the real source of the sadness: conceit. The person is upset because he expected to be above such thoughts. He imagined himself a tzaddik—someone whose mind is a sanctuary of pure contemplation. The intrusion of a base desire shattered his self-image, and that is what really hurts. If he recognized his actual station—a benoni, not a tzaddik—he would understand that struggling with intrusive thoughts is not failure. It is his job description.
More than that: with every push against the sitra achara below, a corresponding suppression happens in the spiritual realms above. The Zohar in Parashat Terumah says that when the forces of impurity are subdued here in this lowest world, God's glory rises "above all"—more than through any song of praise. God specifically wants worship from this dark world, the Tanya says, because the transformation of darkness into light here is more precious than the natural light of the upper worlds.