This is a lifelong struggle. Evil thoughts come from the world when we see people hurting others, or in unholy shows, movies, magazines, sexual displays, etc. Popular songs present evil as good. Our own fallen flesh tempts us with evil. Finally, the devil seeks to destroy us with evil. We cannot rid ourselves of all of these sources. Even if we were to live as hermits in the wilderness, our flesh and our memories would haunt us with evil thoughts.
So, how do we handle evil thoughts? We like the old analogy that we cannot keep birds from flying over our heads but we can keep them from making a nest in our hair. This means we cannot keep out all evil thoughts, but we can choose not to dwell on them. When an evil thought comes into our minds, we might immediately ask God for help to shift our minds and to memorize scripture. Philippians 4:6-9, “Do not be anxious about anything, but in everything by prayer and supplication with thanksgiving let your requests be made known to God. And the peace of God, which surpasses all understanding, will guard your hearts and your minds in Christ Jesus. Finally, brothers, whatever is true, whatever is honorable, whatever is just, whatever is pure, whatever is lovely, whatever is commendable, if there is any excellence, if there is anything worthy of praise, think about these things…What you have learned and received and heard and seen in me–practice these things, and the God of peace will be with you.”â€‹
You might also sing hymns in your heart. Ephesians 5:19-20 (NLT), “singing psalms and hymns and spiritual songs among yourselves, and making music to the Lord in your hearts. And give thanks for everything to God the Father in the name of our Lord Jesus Christ.”â€‹
Finally, thank God for this experience. God will teach you many things through this struggle. You will develop a more Christlike character as you grow closer to Him.â€‹
As praying and shifting your thoughts becomes a habit, it will become easier. God loves you and will certainly give you the wisdom to daily focus on Him. James 1:5 (ESV), “If any of you lacks wisdom, let him ask God, who gives generously to all without reproach, and it will be given him.”