They only want to confuse and test the person. If they are ignored by distracting oneself from them as if they don’t exist, and you must not look back to keep on peeking at them, they evaporate and we discover there was nothing real in them to begin with.
Bad thoughts when presented in our mind are just an illusion. It’s when we absorb this illusion and turn it around in our mind and give it importance that it then becomes a real force with serious consequences.
Once a student came to Rabbi Shmuel and asked him why Chassidim pray with such devotion and slow meditation. Wouldn’t it be better when they have not good thoughts during prayer if they quickly said the words, so there would be no room for the bad thoughts to creep in.
The Rabbi answered. If the thoughts where coming from the outside then perhaps the quick pace would be an answer. The problem is, the thoughts are on the inside, and at this point they emanate from within the mind of a person. The only way to deal with them is to stand up to the enemy and do what it takes for them to be pushed out of the mind.
The strength that is drawn from inside to prevail and triumph over the challenging thoughts is the purpose why G-d put us here in this world. When conquered, a person’s soul is one more inch liberated from the opposing forces. When victorious over bad thoughts, there is a freedom and strengthening for the soul.
The internal struggle with thoughts is specifically strongest when a person is seeking to be spiritual. It is when he tries to elevate himself more spiritually, that the evil inclination feels his position being threatened.
The more a person tries to be spiritual the more they can expect the internal struggle to take place. This sudden struggle is proof that his decision is meaningful and significant. Rather than feel despondent when these thoughts come in, that perhaps the person is not doing something right, to the contrary, it means someone is resentful and putting up a fight.
When a person is fighting with someone else, the harder the opponent tries the harder the other must fight.
The way to deal with these thoughts is not to try and figure them out, as we mentioned earlier, it is to strengthen our concentration in the prayer and not give any attention whatsoever to the challenging thoughts.
One technique is to look in the book while praying. Letters have power to capture and focus a persons mind so the mind pays no heed to any interference. And there are other many other things that can be done to help focus and strengthen the mind.
In mysticism it tells us, every time a person denies a bad thought from the door of his mind, this weakens the general strength of evil in the world, and G-d is very happy with that. Therefore a person should see these challenges as a great opportunity to prove himself. He should be cheerful and grateful after the fact, that these challenges are presented to him.