Infections and mental disorders are two of the major global disease burdens. While correlations between mental disorders and infections have been reported, the possible genetic links between them have not been assessed in large-scale studies. Moreover, the genetic basis of susceptibility to infection is largely unknown, as large-scale genome-wide association studies of susceptibility to infection have been lacking. We utilized a large Danish population-based sample (N = 65,534) linked to nationwide population-based registers to investigate the genetic architecture of susceptibility to infection (heritability estimation, polygenic risk analysis, and a genome-wide association study (GWAS)) and examined its association with mental disorders (comorbidity analysis and genetic correlation). We found strong links between having at least one psychiatric diagnosis and the occurrence of infection (P = 2.16 × 10−208, OR = 1.72). The SNP heritability of susceptibility to infection ranged from ~2 to ~7% in samples of differing psychiatric diagnosis statuses (suggesting the environment as a major contributor to susceptibility), and polygenic risk scores moderately but significantly explained infection status in an independent sample. We observed a genetic correlation of 0.496 (P = 2.17 × 10−17) between a diagnosis of infection and a psychiatric diagnosis. While our GWAS did not identify genome-wide significant associations, we found 90 suggestive (P ≤ 10−5) associations for susceptibility to infection. Our findings suggest a genetic component in susceptibility to infection and indicate that the occurrence of infections in individuals with mental illness may be in part genetically driven.