Animals quickly learn to avoid predictable danger. However, if pre-exposed to a strong stressor, they do not display avoidance even if this causes continued contact with painful stimuli [1, 2]. In rodents, lesioning the habenula, an epithalamic structure that regulates the monoaminergic system, has been reported to reduce avoidance deficits caused by inescapable shock [3]. This is consistent with findings that inability to overcome a stressor is accompanied by an increase in serotonin levels [4]. However, other studies conclude that habenula lesions cause avoidance deficits [5, 6]. These contradictory results may be caused by lesions affecting unintended regions [6]. To clarify the role of the habenula, we used larval zebrafish, whose transparency and amenability to genetic manipulation enables more precise disruption of cells. We show that larval zebrafish learn to avoid a light that has been paired with a mild shock but fail to do so when pre-exposed to inescapable shock. Photobleaching of habenula afferents expressing the photosensitizer KillerRed causes a similar failure in avoidance. Expression of tetanus toxin in dorsal habenula neurons is sufficient to prevent avoidance. We suggest that this region may signal the ability to control a stressor, and that its disruption could contribute to anxiety disorders.