Allah, the Most High, said: “Your companion [Muhammad] has not strayed, nor has he deviated.” (al-Najm 53:2) Indeed, the Messenger did not go astray or deviate. The attribute of misguidance is coupled with deviation because every deviation is going astray. Further to the point, right guidance is used to mean the opposite of deviation while guidance is the opposite of misguidance. The meaning of ‘guidance‘ is to avoid the path of the immoral and people of innovation, which the righteous predecessors used to prohibit – this is to say, immorality and innovation.
Allah, the Exalted, said, “So they were followed by successors who neglected the prayer and followed desires. Thus they will be thrown into ghayyan.” (Maryam 19:59) The word ‘ghayyan‘ (deviation) is a verbal noun that means the opposite of right guidance, as explained by the ayah wherein the two words are used to oppose each other: “And if they see the path of right guidance, they do not take it; and if they see the path of deviation, they take it as a path.” (al Araf 7:146)
As for the term ‘right guidance’, it refers to the deeds that benefit its doer while the term ‘deviation’ refers to all the deeds that harm its doer. It is for this reason, performing good deeds is considered right guidance, and performing acts of evil is considered deviation. This meaning is clear in the ayah wherein the Jinn used the two terms to mean the opposite of each other: “And indeed we do not know whether evil is intended for those who are on the earth or their Lord intends right guidance for them.” (al-Jinn 72:10) and at the end of the surah, the word ‘harm’ was used as opposite to the word ‘right guidance’ – “Say: ‘Indeed I have no control to harm you or over right guidance.” (al-Jinn 72:21)
The word ‘al-Rashid‘ was derived from the root word ‘al-rushd‘ (right guidance) and it means the one who can be entrusted to handle their wealth for they spend it only on what is beneficial. To elaborate further, Allah, the Most High, mentioned in the Qur’an that the Shaytan said: “And truly I will cause all of them to stray except Your slaves among them, those who are sincere.” (al-Hijr 15: 39-40) which is to mean that he wants to command humans to do evil that brings forth harm to them and then they obey him, just as Allah, the Most High, said: “And I did not have authority over you, except that I invited you, then you responded to me.” (Ibrahim 14:22) and He said: “And the Hell-Fire appeared to those who strayed.” (al-Shura 26:91) up to: “Then they will be thrown against one another in it, them and those who strayed, and the armies of Shaytan altogether.” (al-Shura 26:94-95) and “Those against who the statement proves true will say: ‘Our Lord, there are those who led us astray, and we led them astray just as they did to us.” (al-Qasas 28:63) and “Your companion [Muhammad] has not strayed nor has he deviated.” (al-Najm 53:2)
Therefore when ‘deviation‘ is used as a noun for an act of evil that harms its doer, then the result of the act is also called ‘deviation‘ just as the result of a good deed is called ‘right guidance‘. The result of wickedness is called evil, the result of a benefit is called good, the result of a good deed are virtues and the result of evil deeds are sins. Thus ‘good deeds‘ and ‘sins‘ in the Book of Allah are intended to mean ‘acts of good‘ and ‘acts of evil‘, just as blessing, calamities and recompense are a type of act. That said, whoever performs good and good deeds will obtain good and good deeds, and whoever performs evil and sins will obtain evil and sins. As such, whoever errs will obtain sin. Abandonment of the prayer and following desires are errors that will make oneself subject to sins. Due to this, al-Zamakhshari said: ‘Every evil according to the Arabs is deviation, and every good is right guidance.’ Al-Zajjaj said: ‘His recompense is punishment for sins, due to the ayah: “..will obtain sins.” (al-Furqan 25:68) in other words punishment for sins. On the other hand, Allah, the Exalted, said: “…they neglect the prayer and follow desires.” (Maryam 19:59) and the prayer is about seeking the Face of Allah, as He, the Exalted, said, “And do not drive away those who call their Lord day and night desiring His face.” (al-Anam 6:52) referring to the Fajr and Asr prayers. Those who call their Lord are seeking the pleasure of their Lord and desiring to obey Him, thus their hearts, when obeying Him are desirous to please their Lord and loving Him.
Gardens of Purification by Ibn Taymiyyah Pages 35-39