Sin and temptation can go together, but are not the same thing.
Temptation usually starts as a harmful thought. If I keep the thought in my mind and dwell on it could become a sin, if I act on it, it can become a sin. If I can refocus my mind to where God wants, or to where I want, I have not sinned, I have resisted temptation.