www.sefaria.org/Likkutei_Etzot%2C_Thoughts?lang=en A person can’t always stop bad thoughts from entering his mind in the first place. But he does have the power to reject them once he becomes conscious of them. This is something very important, because it is the way to make amends for sins he may have committed earlier in his life. Perfect repentance has to balance the original sins exactly, and this is literally what happens here. Before, when he sinned, it was because the temptation entered his mind and he succumbed to it. Now the thought is in his mind again, but this time he rejects it. So don’t feel discouraged if you find all kinds of temptations and fantasies continually pressing in on your mind. They are actually providing you with the opportunity to repent and make amends for the damage done in the past. Today you have the power to master your thoughts and temptations. When you do so, the sparks of holiness which fell because of your earlier transgressions are released, and you are able to purify yourself.
When a person admits unholy thoughts to his mind, the holiness of his mind is reduced in direct proportion to the space occupied by these degraded thoughts. If you stick a pole in a river bed, all kinds of dirt and filth gather round it. In the same way, all kinds of bad characteristics develop because of these unholy ideas, and the mind is assailed with desires and temptations. In fact all the sins a person does are ultimately caused by the unholy ideas he originally admitted to his mind. To achieve true repentance, you must rid your mind of these thoughts. The mind is the soul, and when a person sanctifies his mind, he elevates and returns everything to its root. This is the essence of repentance (35:1). Unholy thoughts are the “folly of the heart.” When a person dwells on such thoughts his heart becomes sullied and the “foreskin of the heart” grows thick. The “void” of the creation is spoiled, and it is as if this person had damaged the whole world. But when he thinks good thoughts, the creation is restored. When a person purifies his heart and expels all unholy thoughts from his mind, thinking only good thoughts, he can bring about real miracles (49:1). A person’s entire destiny — for good or ill — depends on the thoughts in his heart. The thoughts and ideas in the heart are the basis of the heart’s “inclinations” — the good inclination and the evil inclination. Good thoughts are the good inclination, bad thoughts are the evil inclination (
Ibid.).
Many people experience very strong mental distractions while they are trying to pray. These can be immoral fantasies or even thoughts about idolatrous worship. There are even cases where people see vivid images of idolatrous objects or else they experience overwhelming temptations the very moment they stand up to pray. They try to push the thoughts out of their minds by tossing their heads from side to side. But the harder they try the more the thoughts press in. This is in the nature of thoughts like these. The more worked up you get about trying to push them out of your mind, the more they insinuate their way in. The best way to deal with them is simply to ignore them. Act as if you were completely unconcerned. Refuse to listen. Carry on with what you were doing — studying, praying, working or whatever. Pay no attention to the thoughts or fantasies at all. Don’t keep on looking round to see if they have gone away. Just carry on with what you are trying to do. In the end they will go away of their own accord.
If you allow yourself to be depressed about these kinds of thoughts it simply feeds them with more fuel. It is no good being upset or afraid of them. Just don’t pay any attention to them. Try and be cheerful. ...Eventually these thoughts will disappear automatically. Don’t keep on testing to see if they are still there. It won’t help if you keep on turning round to look. Just don’t pay any attention to them at all (
Ibid.).
The simple fact is that it is impossible for two thoughts to be in the mind at one and the same time. It is therefore an easy matter to rid yourself of bad thoughts by being quite passive. Simply don’t think them. Think something else instead — think about Torah or devotion to God, or even about your work, and so on. If you just turn your mind to something else the bad thoughts and fantasies will go away automatically (
Ibid.).
A person’s thoughts are in his power completely. He can turn them in whatever direction he wants. It may be that at times your thoughts run wild and fly to areas you ought to keep away from. It is still within your power to take them in hand, even against their will, and direct your thoughts to the true path. Thought is just like a horse which turns aside from the road and tries to go in the wrong direction. The rider controls the horse with the bridle and forces it to go in the right direction. As soon as you see your thoughts pulling in the wrong direction, take them in hand and bring them back to the right direction (
Ibid. 50).