Temptation is not sin. It is one of the weapons that the devil employs in his attempts to try and lead us into sin, but it is not sin in and of itself. Every person who walks the face of this earth will be faced with temptation at some point in his or her life. Even Jesus was faced with temptation, but He did not sin (Hebrews 4:15).
Because Jesus faced temptation, He is able to empathize with our human weaknesses. Jesus is fully God but, while He was here on earth, He was also fully human with all the weaknesses that we humans all have. Despite that, Jesus resisted temptation and He did not sin. And because He faced temptation, because He knows what it is like, He is able to help us when we are tempted (Hebrews 2:18).
Immediately following His baptism in the Jordan River, Jesus spent forty days in the wilderness, fasting and praying. No doubt Jesus was weak after forty days with no food, and it was then that He faced temptation. The devil tried to take advantage of Jesus' weakened state and tempt Him to use His power for His own personal benefit rather than for the glory of God. But Jesus overcame that temptation. How did He do it? Through the most powerful weapon that exists to fight against the schemes of the devil, the two-edged sword known as the Word of God. Jesus responded to each of the devil's temptations with God's Word.
If we are to avoid temptation, like Jesus, we need to know God's Word. His Word must be in our hearts and in our minds. When we have God's Word tucked away in our hearts, we have a mighty weapon with which we can fight off temptation and avoid the sin it can lead to (Psalm 119:11). God's Word can protect our hearts. Since everything that we do in life flows from our hearts, we must be sure to guard our hearts (Proverbs 4:23), and what better way to do that but with the Word of God.
To resist temptation, we must also be vigilant and be in prayer. In the Garden of Gethsemane on the night before He died, Jesus told His disciples that they should watch and pray so that they could avoid temptation (Matthew 26:41). Jesus knew that, though their spirits were willing, their flesh was weak. This is true for us, as well. The devil knows that, too, and he will look for any opportunity to exploit that. If we fail to use self-control and don't stay alert to his schemes, the devil will devour us (1 Peter 5:8). But, when we pray and submit our lives to God, we can resist the devil (James 4:7) and the temptations that he throws at us.