Objective There have been conflicting reports on the relationship between thyroid function and mood between studies in subjects on T4 and the general population not on T4. We investigated this relationship in a large catchment area-based study.Design We analysed data on serum TSH levels and Hospital Anxiety and Depression Scale (HADS) scores from the HUNT 2 study (age ≥ 40 years). Following a test for interaction, analyses were performed separately in females on T4 (n = 1265) and in people not on T4 (males n = 9319 and females n = 17 694).Results More females on T4 had high depression and anxiety scores than females not on T4 (depression 18·4%vs. 13·0%, P <0·001, anxiety 23·4%vs. 18·7%, P <0·001). In those not on T4, there was an inverse association between serum TSH and depression score in males (B coefficient = –0·61, 95% CI –0·91 to –0·24, P = 0·001) though not in females (B coefficient = –0·07, –0·33 to 0·19), and an inverse association between TSH and anxiety score in both genders (B coefficient for males = 0·68, 95% CI –1·04 to –0·32, P <0·001; females –0·37, 95% CI –0·67 to –0·08, P = 0·01). In contrast, in females on T4, TSH was positively associated with both depression (B coefficient = +0·27, 95% CI 0·02 to 0·51, P <0·05) and anxiety (B coefficient = +0·29, 95% CI 0·01 to 0·56, P <0·05).Conclusions There is a different relationship between thyroid function and depression and anxiety in females on T4 compared with individuals with no thyroid disease. This group also has a higher prevalence of depression and anxiety.