Box jellyfish have an impressive set of 24 eyes of four different types, including eyes structurally similar to those of vertebrates and cephalopods [1, 2]. However, the known visual responses are restricted to simple phototaxis, shadow responses, and object avoidance responses [3-8], and it has been a puzzle why they need such a complex set of eyes. Here we report that medusae of the box jellyfish Tripedalia cystophora are capable of visually guided navigation in mangrove swamps using terrestrial structures seen through the water surface. They detect the mangrove canopy by an eye type that is specialized to peer up through the water surface and that is suspended such that it is constantly looking straight up, irrespective of the orientation of the jellyfish. The visual information is used to navigate to the preferred habitat at the edge of mangrove lagoons.