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 thoughts about mundane matters come from the animal soul, except that the divine 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, “Answer not a fool according to his folly, lest thou also be like unto him” (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 he should 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 God 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.
–Rabbi Adin Steinsaltz