To evade their predators, animals must quickly detect potential threats, gauge risk, and mount a response. Putative neural circuits responsible for these tasks have been isolated in laboratory studies. However, it is unclear whether and how these circuits combine to generate the flexible, dynamic sequences of evasion behavior exhibited by wild, freely moving animals. Here, we report that evasion behavior of wild fish on a coral reef is generated through a sequence of well-defined decision rules that convert visual sensory input into behavioral actions. Using an automated system to present visual threat stimuli to fish in situ, we show that individuals initiate escape maneuvers in response to the perceived size and expansion rate of an oncoming threat using a decision rule that matches dynamics of known loom-sensitive neural circuits. After initiating an evasion maneuver, fish adjust their trajectories using a control rule based on visual feedback to steer away from the threat and toward shelter. These decision rules accurately describe evasion behavior of fish from phylogenetically distant families, illustrating the conserved nature of escape decision-making. Our results reveal how the flexible behavioral responses required for survival can emerge from relatively simple, conserved decision-making mechanisms.