Arabic text
عَنْ جَرِيرِ بْنِ عَبْدِ اللهِ رَضيَ اللهُ عنه قَالَ: سَأَلْتُ رَسُولَ اللهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ عَنْ نَظَرِ الْفُجَاءَةِ فَأَمَرَنِي أَنْ أَصْرِفَ بَصَرِي.
Translation
Jarīr ibn ‘Abdullāh (may Allah be pleased with him) reported: I asked the Messenger of Allah (may Allah's peace and blessings be upon him) about the sudden glance, and he commanded me to avert my gaze.
Explanation
Jarīr ibn ‘Abdullāh (may Allah be pleased with him) asked the Prophet (may Allah's peace and blessings be upon him) about a man suddenly and unintentionally looking at an unrelated woman. In response, the Prophet (may Allah's peace and blessings be upon him) ordered him to turn his face to the other side once he knows it, and there is no sin on him.
Source: HadeethEnc.com