Surah Yusuf 12:24
وَلَقَدْ هَمَّتْ بِهِۦ ۖ وَهَمَّ بِهَا لَوْلَآ أَن رَّءَا بُرْهَـٰنَ رَبِّهِۦ ۚ كَذَٰلِكَ لِنَصْرِفَ عَنْهُ ٱلسُّوٓءَ وَٱلْفَحْشَآءَ ۚ إِنَّهُۥ مِنْ عِبَادِنَا ٱلْمُخْلَصِينَ
And she certainly determined [to seduce] him, and he would have inclined to her had he not seen the proof [i.e., sign] of his Lord. And thus [it was] that We should avert from him evil and immorality. Indeed, he was of Our chosen servants.
Translation: Saheeh International
Tafsir
And she certainly desired him she sought sexual intercourse with him and he would have desired her too he would have sought the same had it not been that he saw the proof of his Lord Ibn ‘Abbās said ‘Jacob was made to appear before him and he struck his Joseph’s breast whereupon his sexual desire withdrew from his …
Excerpt from Tafsir al-Jalalayn, commentary on 12:24, via Quran.com. The reader has the full commentary and 9 more tafsirs.