The association between mode of delivery and postnatal depression is uncertain. Mental health history may modify the association. The objective of this study was to determine whether the association between caesarean and postnatal psychological distress (PPD) differs according to long-standing depression/anxiety. Analysis of the UK-based Millennium Cohort Study of women who gave birth 2000-2002 was carried out. The outcomes were PPD at 9months by Rutter Malaise Inventory and actively treated physician-diagnosed depression/severe anxiety at 3years. The exposure was mode of delivery. Adjusted relative risks were estimated using Poisson regression. Effect modification according to long-standing depression/anxiety was investigated multiplicatively and additively. We included 15,936 women, of whom 2346 (13.4%, weighted) reported PPD. Women with long-standing depression/anxiety were at 34% lower risk of PPD following elective caesarean, compared with vaginal birth: relative risk (RR) 4.36 (95% confidence interval [CI] 3.76, 5.05), RR 3.25 (95% CI 2.23, 4.75) and RR 4.92 (95% CI 3.67, 6.59) for vaginal, elective and emergency caesarean births, respectively, with relative excess risk due to interaction (RERI) -1.28 (95% CI -2.73, 0.16), ratio of RRs 0.66 (95% CI 0.42, 1.05). Women with long-standing depression/anxiety were at greatest risk of later treatment following emergency caesarean, with RR 4.95 (95% CI 3.86, 6.34), RR 4.09 (95% CI 2.51, 6.65) and RR 6.74 (95% CI 4.87, 9.32), for vaginal, elective and emergency caesarean births, respectively; RERI 1.79 (95% CI -0.13, 3.71), ratio of RRs 1.36 (95% CI 0.94, 1.99); all RRs with reference to vaginal birth in the absence of long-standing depression/anxiety. There was no evidence of a similar association between emergency caesarean and PPD nor elective caesarean and later treatment. Women with long-standing depression or anxiety who had elective caesarean had a lower risk of postnatal distress. When this group had emergency caesarean, there was greater risk of actively treated depression/anxiety at 3years. These associations were not observed in women without long-standing depression/anxiety.