Yusuf - 12:24

وَلَقَدْ هَمَّتْ بِهِ وَهَمَّ بِهَا لَوْلا أَن رَّأَى بُرْهَانَ رَبِّهِ كَذَلِكَ لِنَصْرِفَ عَنْهُ السُّوءَ وَالْفَحْشَاء إِنَّهُ مِنْ عِبَادِنَا الْمُخْلَصِينَ
[12:24]
And certainly she made for him, and he would have made for her, were it not that he had seen the manifest evidence of his Lord; thus (it was) that We might turn away from him evil and indecency, surely he was one of Our sincere servants.
And (with passion) did she desire him, and he would have desired her, but that he saw the evidence of his Lord: thus (did We order) that We might turn away from him (all) evil and shameful deeds: for he was one of Our servants, sincere and purified.
She verily desired him, and he would have desired her if it had not been that he saw the argument of his Lord. Thus it was, that We might ward off from him evil and lewdness. Lo! he was of Our chosen slaves.