Pupil shape in vertebrates ranges from circular to vertical, with multiple phylogenetic shifts in this trait. Our analyses challenge the widely held view that the vertical pupil evolved as an adaptation to enhance night vision. On functional grounds, a variable-aperture vertical pupil (i) allows a nocturnal species to have a sensitive retina for night vision but avoid dazzle by day by adjusting pupil closure, and (ii) increases visual acuity by day, because a narrow vertical pupil can project a sharper image onto the retina in the horizontal plane. Detection of horizontal movement may be critical for predators that wait in ambush for moving prey, suggesting that foraging mode (ambush predation) as well as polyphasic activity may favour the evolution of vertical pupil shape. Camouflage (disruption of the circular outline of the eye) also may be beneficial for ambush predators. A comparative analysis in snakes reveals significant functional links between pupil shape and foraging mode, as well as between pupil shape and diel timing of activity. Similar associations between ambush predation and vertically slit pupils occur in lizards and mammals also, suggesting that foraging mode has exerted major selective forces on visual systems in vertebrates.