Sayyiduna Jarir (may Allah be pleased with him) narrates: I asked the Prophet Muhammad (peace and blessings be upon him) about an accidental glance, so he instructed me to turn my gaze away.
(Imam Ibn Hibban, may Allah have mercy on him, says:) The command to turn the gaze away is obligatory regarding that which is not permissible, and this is combined with the prohibition of its opposite, and that is, it is forbidden to look at that which has been declared unlawful.