Oh I've had this, first I refuted and rebuked the spirit and ordered it away in the name of Jesus, then I petitioned Jesus Christ to remove the spirit ( I took it as a demon). The next day I spoke out loud that you do not have a right to me, it's useless because I belong to Jesus Christ, so go away. Next came a vision out of a dream in which I was confronted by the source, Satan. And then it was gone. These enter you by projections. Something interesting I found in my studies of this stuff is Satan has access through any crack in our armor and he can shoot in a fiery dart, an impression if you will. But Satan does not have access to our silent thoughts. You want to keep yourself in the full light of Jesus Christ, your faith up and your full armor of God on. You access the full armor of God through the Word of God.
So an impression enters your mind ( could be some sort of sin or a weakness in your faith, just about anything as long as your guard is down). Once you have this thought it then festers in your mind, we are capable of turning that into all sorts of things which brings more doubt. You have to root it out by drawing nearer to Jesus. What I mentioned above is what worked for me. Also remember that Satan is allowed a certain amount of access to you according to God's will, just read the book of Job. Job is the perfect lesson in this stuff.