Objective: Migraines are one of the most common neurological disorders. Dementia is a neurodegenerative disease characterized by slow progressive memory loss and cognitive dysfunction. This retrospective cohort study investigates the association between migraines and dementia using a nationwide population-based database in Taiwan. Methods: We retrieved the data analyzed in this study from the National Health Insurance Research database (NHIRD) in Taiwan. We used multivariate Cox proportion-hazards regression models to assess the effects of migraines on the risk of dementia after adjusting for sociodemographic characteristics and comorbidities. Results: The migraine cohort had a higher prevalence of diabetes, hypertension, coronary artery disease, head injury and depression at baseline (p < 0.0001). After adjusting the covariates, migraine patients had a 1.33-fold higher risk of developing dementia [hazard ratio (HR) 1.33, 95% confidence interval (CI) 1.22-1.46]. The sex-specific incidence rate of dementia was higher in men than in women in both cohorts, with an HR of 1.09 (95% CI 1.00-1.18) for men compared to women. Kaplan-Meier analysis shows that the cumulative incidence of dementia was 1.48% greater in the migraine cohort than in the nonmigraine cohort (log-rank test, p < 0.0001). Conclusions: This study shows that migraines are associated with a future higher risk of dementia after adjusting for comorbidities. Specifically, the association between migraine and dementia is greater in young adults than in older adults.