To survive in evolving environments with uncertain resources, animals need to dynamically adapt their behaviour and exhibit flexibility in choosing appropriate behavioural strategies, for example, to persevere in exploiting a current choice, to explore alternative options and acquire novel information, or to disengage altogether. Previous studies have mainly investigated how forebrain regions represent choice costs and values as well as optimal strategies during such decisions. However, the neural mechanisms by which the brain implements alternative behavioural strategies such as persevering, exploring or disengaging from the environment, remains poorly understood. Here we identify a neural hub critical for flexible switching between behavioural strategies, the median raphe nucleus (MRN). Using cell-type specific optogenetic manipulations, calcium fibre photometry and circuit tracing in mice performing diverse instinctive and learnt behavioural tasks, we found that the MRN's main cell types, GABAergic, glutamatergic (VGluT2-positive), and serotonergic neurons, have complementary functions and drive perseverance, exploration and disengagement, respectively. Suppression of MRN GABAergic neurons, for instance through inhibitory input from lateral hypothalamus which conveys strong positive valence to the MRN, leads to perseverance in current actions and goals. In contrast, activation of MRN VGluT2+ neurons drives exploratory behaviour. Activity of serotonergic MRN neurons is necessary for general task engagement. Input from the lateral habenula conveying negative valence suppresses serotonergic MRN neurons, leading to disengagement. These findings establish the MRN as a central behavioural switchboard, uniquely positioned to flexibly control behavioural strategies. These circuits thus may also play an important role in the aetiology and possible treatment of major mental pathologies such as depressive or obsessive-compulsive disorders.