Cognitive and behavioural flexibility permit the appropriate adjustment of thoughts and behaviours in response to changing environmental demands. Brain mechanisms enabling flexibility have been examined using non-invasive neuroimaging and behavioural approaches in humans alongside pharmacological and lesion studies in animals. This work has identified large-scale functional brain networks encompassing lateral and orbital frontoparietal, midcingulo-insular and frontostriatal regions that support flexibility across the lifespan. Flexibility can be compromised in early-life neurodevelopmental disorders, clinical conditions that emerge during adolescence and late-life dementias. We critically evaluate evidence for the enhancement of flexibility through cognitive training, physical activity and bilingual experience.