Throughout the COVID-19 pandemic, research has centred on understanding why some people infected with the SARS-CoV-2 virus experience severe disease. However, 10-30% of individuals with the virus do not show any symptoms. Investigating asymptomatic infection could shed light on features of the immune system that help to eliminate SARS-CoV-2. Here, postulating that variation in the human leukocyte antigen (HLA) loci may underly processes mediating asymptomatic infection, we investigated the genetics of almost 30,000 registered bone marrow donors who participated in a voluntary program to track COVID-19 infection and symptoms1. Our analysis revealed a strong association between HLA-B*15:01 and asymptomatic infection, observed in two independent cohorts. Suggesting that this genetic association is due to pre-existing T cell immunity, we show that T cells from pre-pandemic samples from individuals carrying HLA-B*15:01 were reactive to the immunodominant SARS-CoV-2 Spike-derived peptide NQKLIANQF. The majority of the reactive T cells displayed a memory phenotype, were highly polyfunctional and were cross-reactive to a peptide derived from seasonal coronaviruses (NQKLIANAF). The crystal structure of HLA-B*15:01–peptide complexes demonstrates that the peptides NQKLIANQF and NQKLIANAF share a similar ability to be stabilized and presented by HLA-B*15:01. Finally, we show that the structural similarity of the peptides underpins T cell cross-reactivity of high-affinity public T cell receptors, providing the molecular basis for HLA-B*15:01-mediated pre-existing immunity1. Our findings have major implications for public health because such knowledge could inform the design and development of vaccines and therapies for COVID-19. More broadly, identifying genetic factors that control the course of the disease could begin to explain the wide variation in how people respond to SARS-CoV-2 and other viral infections.