As We rescued Yusuf from the plot of his brethren, We made him firm and granted him a high position in Egypt, and to teach him the explanation of visions. Verily, Allah does whatever He wants and His Command cannot be rejected or violated, but most people do not know His Wonders, Favors, and His Wisdom behind creation.
﴿وَلَمَّا بَلَغَ أَشُدَّهُ آتَيْنَاهُ حُكْماً وَعِلْماً وَكَذَلِكَ نَجْزِي الْمُحْسِنِينَ﴾ (يوسف: 22)
22 - When he became of age and his power completed, We gave him prophethood and taught him the explanation of visions as a result of his perfection in work, his perfection in obeying his lord, and observation of patience during his trial.
This is the description of Yusuf's condition. This does not mean that he was given prophethood in this position of the story if we interpret the word "Hukman" with prophethood which we shall explain later as Allah says: "And (remember) Lout (Lot), We gave him Hukman (right judgment of the affairs and Prophethood) and (religious) knowledge." [Surat Al Anbiya': 74]. However, if it is interpreted by knowledge and understanding religion, there will be no problem.
(وَرَاوَدَتْهُ الَّتِي هُوَ فِي بَيْتِهَا عَن نَّفْسِهِ وَغَلَّقَتِ الأَبْوَابَ وَقَالَتْ هَيْتَ لَكَ قَالَ مَعَاذَ اللّهِ إِنَّهُ رَبِّي أَحْسَنَ مَثْوَايَ إِنَّهُ لاَ يُفْلِحُ الظَّالِمُونَ) (يوسف: 23)
23 - The wife of Al `Aziz called him, asked him to have sexual intercourse with her, closed the doors, and said to him: Hurry up, for I am ready for you.
Yusuf (peace be upon him) said: I seek refuge in Allah and hold firm with him of what you ask me to do. Your husband has been kind to me and honored me, so how could I cheat on him? Indeed, those who meet goodness with evil shall not succeed and shall not win in the world or in the Hereafter.
﴿وَلَقَدْ هَمَّتْ بِهِ وَهَمَّ بِهَا لَوْلا أَن رَّأَى بُرْهَانَ رَبِّهِ كَذَلِكَ لِنَصْرِفَ عَنْهُ السُّوءَ وَالْفَحْشَاء إِنَّهُ مِنْ عِبَادِنَا الْمُخْلَصِينَ﴾ (يوسف: 24)
24 - The wife of Al `Aziz made up her mind to have sexual intercourse with him, and he inclined to her in some moments according to his human nature, but that inclination did not exceed his mind to his heart. When the signs of Allah appeared to him to make him firm, remind him of the bad consequence of fornication, and strengthen his will by patience and piety, the light of faith lightened strongly in his heart again. So, he took a lesson, repented to Allah, and sought refuge in Allah against Satan and did not do anything with her.
As We showed him a proof and caused him to turn away from her, We turn away cheating and fornication from him, for he is one of Our Chosen Servants whom We chose for obeying us, honored with prophethood, and protected against anything that may slander his behavior and biography.
﴿وَاسُتَبَقَا الْبَابَ وَقَدَّتْ قَمِيصَهُ مِن دُبُرٍ وَأَلْفَيَا سَيِّدَهَا لَدَى الْبَابِ قَالَتْ مَا جَزَاء مَنْ أَرَادَ بِأَهْلِكَ سُوَءاً إِلاَّ أَن يُسْجَنَ أَوْ عَذَابٌ أَلِيمٌ﴾ (يوسف: 25)
25 - Yusuf escaped to the door to get rid of her, and she followed him to prevent him from escape. So, she gripped him from the back and pulled him powerfully to tear up his shirt. Yusuf continued to escape and she was running after him, and when they came out of the room, they found her husband at the door. She feared and said to her husband: What is the punishment of he who wants to practice fornication with your wife?
She feared that he would kill him while she is still in love with him, so she said: The punishment should be either detention or harsh beating.