Stereotypies are common in captive animals, but it remains unclear if they are pathological by-products of captive conditions or if they have an adaptive function. Here, we address this question using crib-biting, a common type of stereotypic behaviour in domestic horses, thought to result from stressful or frustrating environments. Since chronic stress is known to affect learning abilities via dopaminergic modulation in the basal ganglia, we predicted that stereotypic horses would underperform in learning tasks compared to healthy control animals, in line with the pathological by-product hypothesis. We exposed 19 crib-biters and 18 control horses in six spatial tasks, and collected behavioural and physiological data (heart rate, heart rate variability and salivary cortisol) to assess learning performance and stress levels. We found that, during the learning phase, 10 of 19 crib-biters showed stereotypic behaviour. Surprisingly, crib-biters that displayed the stereotypic behaviour (Group A) had lower salivary cortisol values compared to crib-biters that did not display the stereotypic behaviour (Group B) or control horses (Group C), after the first part of the experiment. In addition, a smaller proportion of horses in Group A displayed behaviours indicating frustration during one of the test compared to Group B. Moreover, we found no difference between the three groups in their learning performance nor in their heart rate or heart rate variability measures. Our results therefore suggest that crib-biting has an adaptive function and can help horses to reduce stress and frustration during learning tasks, which then enables them to show normal learning performance.