Resist Satan 

Brothers and Sisters, do not give the devil a strong hold. Eph 4:27 (NIV). When the devil attacks our mind (imagination) we must resist. Immorality is first committed in the mind, the imagination, the fantasy realm, before it is committed in the flesh. See Matt 5:27-28. When the devil attacks our mind, and he does, we must immediately reject him. Do not give him an opportunity. Eph 4:27. 

Verbally (both out loud and internally) reject satan's attacks. If, for example, an improper image comes into your mind from something you see on TV or at the checkout stand at the grocery store we must reject the images. Declare God's victory over satan, reject all impure thoughts, and claim our membership in the family of God. If doubt, despair, or other attacks come knocking at our mind's door, we must learn to repel them at the gates by verbally rejecting satan and his minion and not letting them in to linger. 

We are not responsible for satan attacking us. Just as we cannot stop birds from flying around our heads, we cannot stop satan from trying to destroy us. But, while you cannot stop the birds from flying around your head, you can keep them from building a nest in your hair. Likewise, we can stop satan from building a nest in our minds. 

The apostle Paul teaches that we are able, in Christ, to put to death the deeds of the flesh because our old self was bought and paid for by Christ. Romans 6:1-23. We walk in the Spirit and must use the Spirit to repel the devil from the gates of our mind. Romans 8:1-2 and 5-6.

 The devil attacks with doubt, fear, lust, envy, boastfulness and pride (not a full list). These are the things of the world, not of God. We must continually pray for protection and grace and we must reject the attitudes of satan. 

Submit therefore to God. resist the devil and he will flee. Draw near to God and God will draw near to you. James 4:7-8 (NASB)