Commentators are unanimous about her (Zulaikha) intention of disobedience but disagree about his own intention. There are those who say that she tempted him and he tempted her to sin, although he did not follow through with his intent. Others say that she merely wanted him to kiss her, and he attempted to strike her. Yet others say that this anxiety had been there before this incident. There was a psychological disturbance in Joseph when he reached adolescence, which Almighty Allah rid him of.
The safest commentary for us is that there is temptation and resistance in the verse, for He Most High stated: And indeed she did desire him and he would have inclined to her desire..." Surah 12: 24
Abu Ubaidah said that this is a temptation and resistance meaning that she had tried to seduce him; had he not seen the proof of Allah, he would have been seduced. This is in keeping with the infallibility of prophets, as it suits the words which immediately follow: Thus it was, that We might turn away from him evil and illegal sexual intercourse. Surely, he was one of Our chosen, guided slaves. Surah 12: 24
This verse proves that Joseph was an upright worshiper of Allah; it also testifies to his rescue from the authority of Satan. The Almighty said to the devil (Iblis) on the Day of Creation, "Certainly, you shall have no authority over My slaves, except those who follow you of the Ghawin (Mushrikeen and those who go astray, criminals, polyt heists, and evil-doers, etc.)" Surah 15: 42