Aims The aim of this cross-sectional population-based study was to investigate the associations between migraine and type 1 and type 2 diabetes mellitus (DM). Methods We used data from the second (1995-1997) and third survey (2006-2008) in the Nord-Trøndelag Health Study. Analyses were made for the 26,121 participants (30-97 years of age, median 58.3 years) with known headache and DM status in both surveys, and for the 39,584 participants in the third survey (20-97 years, median 54.1 years). The diagnosis of migraine was given to those who fulfilled the questionnaire-based migraine diagnosis in the second and/or third survey. Associations were assessed using multiple logistic regression, estimating prevalence odds ratio (OR) with 95% confidence intervals (CIs). Results In the multivariate analysis of the 26,121 participants in both surveys, adjusting for age, gender, years of education, and smoking, classical type 1 DM (n = 81) was associated with a lower prevalence of any headache (OR = 0.55, 95% CI 0.34-0.88),and migraine (OR = 0.47, 95% CI 0.26-0.96) compared to those without DM (n = 24,779). Correspondingly, the merged group of classical type 1 DM and latent autoimmune diabetes of adults (LADA) (n = 153) were less likely to have migraine (OR = 0.53, 95% CI 0.31-0.91). Similarly, an inverse relationship between type 1 DM and migraine was found in analyses of 39,584 participants in the third survey. No clear association was found between headache and type 2 DM. Conclusions In this cross-sectional population-based study of mainly middle-aged participants, type 1 DM was inversely associated with headache, in particular migraine.