Background Herpes simplex virus-1 (HSV-1) infection is reported to be associated with depression. But limited efforts were made to investigate the relationship between HSV-1 infection and the risk of depression, especially from the genetic perspective. Methods In UK Biobank cohort, linear and logistic regression analyses were first performed to test the association of HSV-1 seropositivity/antibody with depression, including depression status (N = 2951) and Patient Health Questionnaire (PHQ) score (N = 2839). Using individual genotypic and phenotypic data from the UK Biobank, genome-wide environmental interaction study (GWEIS) was then conducted by PLINK2.0 to evaluate gene x HSV-1 interacting effect on the risk of depression. Finally, gene set enrichment analysis was conducted to identify the biological pathways involved in the observed gene x HSV-1 interaction for depression. Result In UK Biobank cohort, significant associations were observed between depression status and HSV-1 (odds ratio [OR] = 1.09; 95% confidence interval [CI], 1.02-1.16;P = 2.40 x 10(-2)for HSV-1 antibody and OR = 1.28; 95% CI, 1.12-1.47,P = 2.59 x 10(-3)for HSV-1 seropositivity). GWEIS revealed four significant gene x HSV-1 interaction signals for PHQ score (allP < 5.0 x 10(-8)) and the leading loci was SULF2 (rs6094791,P = 8.60 x 10(-9)). Pathway analyses identified 21 pathways for PHQ score and 19 for depression status, including multiple neural development- and immune-related ones, such as KEGG_NEUROACTIVE_LIGAND_RECEPTOR_INTERACTION (false discovery rate [FDR] = 3.18 x 10(-2)) for depression and LU_AGING_BRAIN_UP (FDR = 4.21 x 10(-2)) for PHQ score. Conclusion Our results suggested that HSV-1 was associated with the risk of depression, which was modulated by the several genes that were related to the nerve development or immune function.