Objective We aimed to evaluate associations of human leukocyte antigen variants with migraine or headache in hospital and population-based settings. Methods The case-control study population, aged 30–70, included 605 clinic-based migraine patients in a medical center and 8449 population-based participants in Taiwan Biobank (TWB). Clinic-based cases were ascertained by neurologists. Participants in Taiwan Biobank were interviewed by a structured questionnaire including headache and migraine history; among them, 2394 had headache or migraine history while 6055 were free of headache and served as controls. All subjects were genotyped by Axiom Genome-Wide Single Nucleotide Polymorphism Arrays and imputed for eight classical human leukocyte antigen genes. Human leukocyte antigen frequencies were compared between clinic-based and self-reported patients and controls. We utilized likelihood ratio tests to examine human leukocyte antigen-disease associations and logistic regressions to estimate the effect of human leukocyte antigen alleles on migraine. Results Human leukocyte antigen -B and C showed significant associations with clinic-based migraine ( q-value < 0.05). Human leukocyte antigen -B*39:01, human leukocyte antigen -B*51:01, human leukocyte antigen -B*58:01 and human leukocyte antigen -C*03:02 were significantly associated with migraine, with age and sex-adjusted odds ratios (95% CIs) of 1.80 (1.28–2.53), 1.50 (1.15–1.97), 1.36 (1.14–1.62) and 1.36 (1.14–1.62), correspondingly. Clinic-based migraineurs carrying human leukocyte antigen -B*58:01 or human leukocyte antigen -C*03:02 had 1.63 (1.11–2.39) -fold likelihood to have chronic migraine with medication-overuse headache compared to episodic migraine. However, no human leukocyte antigen genes were associated with self-reported headache or migraine in the community. Conclusions Human leukocyte antigen class I genetic variants are positively associated with risk of clinic-based migraine but not self-reported migraine or headache and may contribute to migraine chronification and medication overuse.