Intrusive thoughts during prayer are not a sign that your prayer is worthless. They are a sign that your prayer is working.
Chapter twenty-eight of the Tanya addresses one of the most common experiences in spiritual life: you sit down to pray with concentration, and within minutes your mind is flooded with distractions—desires, anxieties, random images, fantasies. The natural conclusion is devastating: clearly, my prayer is defective. If I were truly praying, these thoughts would not arise.
Rabbi Schneur Zalman demolishes this conclusion. The reason intrusive thoughts intensify during prayer is that two souls are at war. When the divine soul gathers its strength for concentrated devotion, the animal soul responds by mustering its own forces. It is like two wrestlers: when one pushes harder, the other pushes back. The surge of distraction during prayer is evidence of the animal soul's counterattack—which only happens because the divine soul was genuinely threatening its position.
If the prayer were meaningless, the animal soul would not bother disrupting it.
The Tanya offers a parable. Imagine you are praying with deep devotion, and a wicked person walks up and starts talking to you, trying to break your concentration. What would you do? You would not engage with him. You would not argue. You would not even acknowledge his presence. You would simply continue praying, pretending he is not there.
The intrusive thought is that wicked person. It comes from the animal soul—a separate entity with its own agenda. Engaging with it—either by following the thought or by getting upset about it—gives it power. Ignoring it and returning to prayer is the only correct response.
The Tanya says you should not even try to "elevate" the thought, as some Kabbalistic practices suggest. That technique is for tzaddikim (a righteous person) (the righteous), whose intrusive thoughts come from external sources and can be redirected. For the benoni, whose distracting thoughts come from his own animal soul, trying to elevate them is like trying to lift yourself by your own hair while your feet are chained to the ground. Just ignore the thought, return to prayer, and keep going.
Even if there occur to him lustful imaginations or other extraneous thoughts during Divine service, in Torah or in devout prayer, he must not let his heart dwell on them but must immediately avert his mind from them. Nor should he be foolish by attempting to sublimate the middot of the extraneous thought, as is known. For such things were meant only for tzaddikim, in whom extraneous thoughts do not occur of their own making, but those of others. But as for him whose extraneous thought is his own, from the aspect of evil that is in the left part of his heart, how can he raise it up when he himself is bound below? Nevertheless he must not be downcast at heart and feel dejected and despicable during Divine service, which should be with great joy. On the contrary, he should draw fresh strength and intensify [his] effort with all his power to concentrate on the prayer with increased joy and gladness in the realization that the foreign thought that had invaded his heart comes from the kelipah in the left part, which, in the case of the benoni, wages war with the divine soul within him. For it is known that the way of combatants, as of wrestlers, is that when one is gaining the upper hand, the other likewise strives to prevail with all the resources of his strength. Therefore, when the divine soul exerts itself and summons its strength for prayer, the kelipah also gathers strength at such time to confuse her and topple her by means of a foreign thought of its own. This refutes the error commonly held by people, who mistakenly deduce from the occurrence of the foreign thought that this proves their prayer to be worthless, for if one prayed as is fitting and proper, no foreign thoughts would have occurred to him. What they say would be true if there were only one single soul, the same that prays as well as thinks and fancies the foreign thoughts. The real truth, however, is that there are two souls, waging war one against the other in the person’s mind, each one wishing and desiring to rule over him and pervade his mind exclusively. Thus all thoughts of Torah and the fear of Heaven come from the divine soul, while all mundane matters come from the animal soul, except that the divine soul is clothed in it. This is like the example of a person praying with devotion, while facing him there stands a wicked heathen who chats and speaks to him in order to confuse him. Surely the thing to do in such a case would be not to answer him good or evil, but rather to pretend to be deaf without hearing and to comply with the verse, “Do not answer a fool according to his folly, lest even you become like him.”1 Proverbs 26:4. Similarly, he must answer nothing, nor engage in any argument and counterargument with the foreign thought, for he who wrestles with a filthy person is bound to become soiled himself. Rather should he adopt an attitude as if he neither knows nor hears the thoughts that have befallen him; he must remove them from his mind and strengthen still more the power of his concentration. However, if he finds it hard to dismiss them from his mind, because they distract his mind with great intensity, then he should humble his spirit before G–d and supplicate Him in his thought to have compassion upon him in His abundant mercies, as a father who takes pity on his children who stem from his brain;2 Cf. above, ch. 2. so may G–d have pity on his soul which is derived from Him Who is blessed and deliver it from the “turbulent waters”;3 Allusion to Psalms 124:5. for His sake He will do it, for verily “His people is a part of the L–rd.”4 Deuteronomy 32:9. Thus, by helping the divine soul, G–d helps Himself, as it were.