Overall meaning :
When Joseph attained his full manhood, Allah states, He bestowed on him prophethood and knowledge. Just as We rewarded Joseph for doing good, We, too, reward those who do good. The Chief Minister’s wife, having formed an unlawful affection for Joseph and attempted to seduce him, locked all the doors of the house and said, 'Come to me.’ 'Allah is my refuge!’ he replied. 'I seek His protection from the wicked deed to which you are calling me and from betraying my master who has treated me with such loving kindness and has taken good care of me. Indeed, those who wrong themselves by doing what they must not to do will never succeed.’
The Chief Minister’s wife desired Joseph so much she was determined to commit such a dreadful sin, and he himself desired her—though for him it was merely a passing thought that did not crystallise into determination—and he would have succumbed to her persistent advances had he not seen a sign from his Lord which strengthened his faith and prevented him from disobeying Him. Thus We willed it to be in order to keep evil and indecency away from him, for he was truly one of Our faithful and purified servants whom We had chosen to convey Our message and whom We had guarded against idolatry, evil and immorality.
Joseph rushed to the door to flee out of the room, and she also rushed after him to grab hold of him, and pulling his shirt from behind to prevent him from escaping, she tore his shirt in the process, only to encounter her husband at the door. She said, seeking to accuse Joseph of attempted assault, 'What is the penalty for someone who tried to violate your wife, except to be thrown into prison or to suffer a painful punishment?’ 'It was she who attempted to seduce me and I simply refused,’ Joseph said, protesting his innocence. A member of her own family suggested, judging the case, 'If his shirt is torn from the front, then she has spoken the truth and he is a liar; but if his shirt is torn from the back, then she has lied and he has clearly told the simple truth.’ When her husband perceived that Joseph’s shirt was torn from the back, which made him absolutely certain of Joseph’s innocence, he turned to his wife and said, 'This is an instance of your guile, women! Your guile is great indeed.’ 'Joseph,’ he then said, 'ignore all this and do not mention what happened to anyone; and you, woman, ask pardon for your sin; You have certainly done wrong by trying to seduce him and telling a lie about him.’