Introduction: Antigen presentation and antimicrobial immune responses involve the human leukocyte antigen (HLA) system. Onychomycosis is primarily caused by dermatophytes and affects around 5.5% of the population worldwide. Yet, only limited data exist on the associations between the HLA system and onychomycosis. Thus, the objective of the study was to investigate if there is an association between HLA alleles and onychomycosis. Methods: Participants in the Danish Blood Donor Study were defined as cases of onychomycosis and controls based on antifungal prescriptions in the national prescription registry. Associations were investigated using logistic regressions adjusted for confounders and were Bonferroni corrected for multiple tests. Results: A total of 3,665 participants were considered onychomycosis cases, and 24,144 participants were considered controls. We found two protective HLA alleles of onychomycosis: DQB1∗06:04, odds ratios (OR) 0.80 (95% confidence interval (CI) 0.71-0.90), and DRB1∗13:02, OR 0.79 (95% CI: 0.71-0.89). Conclusion: The finding of two novel protective alleles of onychomycosis indicates that certain HLA alleles have certain antigen presentation properties affecting the risk of fungal infection. These findings may provide the basis for future research identifying immunologically relevant antigens of fungi causing onychomycosis, which could ultimately lead to targets of new drugs with antifungal effects.