Immune dysregulation has been observed in individuals with sleep disturbance, with HLA molecules play a crucial role in the immune response. This study aimed to investigate the associations between HLA alleles and sleep behaviours, considering several environmental factors. Data were sourced from the UK Biobank. Logistic regression analyses were performed to explore the associations between 359 HLA alleles and 4 sleep behaviours, including chronotype (n = 204,636), insomnia (n = 227,553), snoring (n = 214,350) and daytime dozing (n = 227,197). Furthermore, gene-environmental interaction studies (GEIS) were conducted to evaluate the interactions of HLA alleles with environmental factors on sleep behaviours. This study analysed a total sample and subgroups stratified by sex to elucidate the impact of HLA alleles on sleep behaviours. Our findings revealed several associations between specific HLA alleles and sleep behaviours. Notably, HLA-A*23:01 was associated with evening chronotype in the total sample (OR = 0.918, 95%CI: 0.872-0.965), while HLA-A*32:01 was associated with evening chronotype in males (OR = 1.089, 95%CI: 1.037-1.144). Furthermore, GEIS identified multiple sets of interactions associated with sleep behaviours. For example, the interaction of HLA-DPA1*01:04 with alcohol consumption was associated with daytime dozing in the total sample (OR = 1.993, 95%CI: 1.351-2.941), while the interaction of HLA-DQB1*05:04 with ever suffered mental distress preventing usual activities was associated with insomnia in males (OR = 0.409, 95%CI: 0.254-0.658). Our findings highlight the involvement of HLA in sleep regulation and underscore the potential interactions between HLA alleles and environmental factors in modulating susceptibility to sleep behaviours.