One proposed HIV vaccine strategy is to induce Gag-specific CD8(+) T-cell responses that can corner the virus, through fitness cost of viral escape and unavailability of compensatory mutations. We show here that the most variable capsid residues principally comprise escape mutants driven by protective alleles HLA-B*57, -5801, and -8101 and covarying HLA-independent polymorphisms that arise in conjunction with these escape mutations. These covarying polymorphisms are potentially compensatory and are concentrated around three tropism-determining loops of p24, suggesting structural interdependencies. Our results demonstrate complex patterns of adaptation of HIV under immune selection pressure, the understanding of which should aid vaccine design.