It enters the cavernous sinus by piercing the posterior corner of its roof, then runs forwards in the lateral wall of the cavernous sinus between the oculomotor and ophthalmic nerves; in the anterior part of the sinus it crosses over the oculomotor nerve.