Our Lord was tempted in the desert, and all the saints endured temptation - and yet, we so often are surprised to find ourselves weak enough to suffer temptation. However, God permits temptation to help us grow in holiness, especially through gaining the virtue of humility.
There are three stages of sin: Temptation to sin, delectation (delight) in the thought of sin, and consent to commit sin. There are two extremes which we must avoid: Either thinking that temptation is already sin, or thinking that taking delight in thoughts about sin is no sin at all.
How do we resist temptation? By making strong acts of faith, resolving to follow God's commands and trusting that his grace will sustain us. By praying when tempted, and praying before temptation that we will have the grace to pray during temptation. And, by practicing penance.
Listen online [here]!