There are many people that are very anxious and troubled when the thought of sinning comes to their minds. Whilst Shaytaan whispers such thoughts, inviting and tempting towards sins, we should not entertain them.
I often present the analogy that our minds can be likened to a national highway. Whilst traveling on the highway, we find different kinds of vehicles and conveyances – luxury cars, old cars, trucks, bicycles, motorbikes, etc. Many a time, animals are seen being transported – horses, cows and even pigs. If we find ourselves driving behind a truck transporting pigs, then even though it is something that disgusts us, we don’t have to leave off traveling the highway. All we have to do is, indicate, accelerate, overtake and continue driving.
Similarly, our mind is like that national highway and all kinds of thoughts begin traveling the mind – good and bad. When evil thoughts visit our minds, then we should just pass them by. We should not intentionally bring them into the mind or entertain them when they come to mind. Simply ignore them. Despite the thought being bad, no sin is recorded against. In fact Hazrat Abu Hurairah (radhiyallahu anhu) mentioned that Nabi (sallallahu alayhi wasallam) had said that if a servant has an inclination towards some evil but does not act upon it, one good is written of good deeds.
The following is another analogy which I have also presented in explanation : If during the blessed month of Ramadaan, whilst sitting at the dastarkhaan, waiting for iftaar, many delicious foods are placed before a person, and the thought comes to his mind, to eat this or partake of that, then there is no sin in regard to those thoughts. As long as the person does not eat anything, his fast will not break and there will be no sin on the mere thought of eating the different delicacies coming to his mind.