The anterior pituitary is the major link between nervous and hormonal systems, which allow the brain to generate adequate and flexible behaviour. Here, we address its role in mediating behavioural adjustments that aid in coping with acutely threatening environments. For this we combine optogenetic manipulation of pituitary corticotroph cells in larval zebrafish with newly developed assays for measuring goal-directed actions in very short timescales. Our results reveal modulatory actions of corticotroph cell activity on locomotion, avoidance behaviours and stimulus responsiveness directly after the onset of stress. Altogether, the findings uncover the significance of endocrine pituitary cells for rapidly optimizing behaviour in local antagonistic environments.