Giant and colossal deep-sea squid (Architeuthis and Mesonychoteuthis) have the largest eyes in the animal kingdom [1, 2], but there is no explanation for why they would need eyes that are nearly three times the diameter of those of any other extant animal. Here we develop a theory for visual detection in pelagic habitats, which predicts that such giant eyes are unlikely to evolve for detecting mates or prey at long distance but are instead uniquely suited for detecting very large predators, such as sperm whales. We also provide photographic documentation of an eyeball of about 27 cm with a 9 cm pupil in a giant squid, and we predict that, below 600 m depth, it would allow detection of sperm whales at distances exceeding 120 m. With this long range of vision, giant squid get an early warning of approaching sperm whales. Because the sonar range of sperm whales exceeds 120 m [3-5], we hypothesize that a well-prepared and powerful evasive response to hunting sperm whales may have driven the evolution of huge dimensions in both eyes and bodies of giant and colossal squid. Our theory also provides insights into the vision of Mesozoic ichthyosaurs with unusually large eyes.