Polymorphisms in human leukocyte antigen (HLA) genes strongly influence outcomes to HIV infection. However, the underlying mechanisms by which certain alleles mediate protection is not well understood. Here we systematically investigate residues within HLA class I molecules (at positions 67, 70, 97 and 156) that have been demonstrated by genetic studies to explain the observed variation of HLA class I alleles on HIV infection. Through a detailed assessment of the protective HLA-B*5701 allele, we find that each of these residues has distinct effects on either HIV-specific CD8+ T cell recognition (67, 70, 156), stabilization of HLA class I-peptide complexes (67, 156), binding of HLA class I-peptide to HIV-specific T cell receptors (70, 156) or KIR3DL1 (97). Structural analyses illustrate that residue mutations uniquely affect the residue microenvironment of the class I binding groove to impact interactions between HLA-peptide complexes with TCR and KIR. These results thereby provide a structural and mechanistic basis for the HLA association with HIV disease outcome. Moreover, they definitively demonstrate that the major host genetic determinant of HIV control is modulation of the stability and conformation of viral peptides by HLA class I for recognition by both the innate and adaptive immune system.