CD8+ T cell–dependent killing of cancer cells requires efficient presentation of tumor antigens by human leukocyte antigen class I (HLA-I) molecules. However, the extent to which patient-specific HLA-I genotype influences response to anti–programmed cell death protein 1 or anti–cytotoxic T lymphocyte–associated protein 4 is currently unknown. We determined the HLA-I genotype of 1535 advanced cancer patients treated with immune checkpoint blockade (ICB). Maximal heterozygosity at HLA-I loci (“A,” “B,” and “C”) improved overall survival after ICB compared with patients who were homozygous for at least one HLA locus. In two independent melanoma cohorts, patients with the HLA-B44 supertype had extended survival, whereas the HLA-B62 supertype (including HLA-B*15:01) or somatic loss of heterozygosity at HLA-I was associated with poor outcome. Molecular dynamics simulations of HLA-B*15:01 revealed different elements that may impair CD8+ T cell recognition of neoantigens. Our results have important implications for predicting response to ICB and for the design of neoantigen-based therapeutic vaccines.