Escape from T cell-mediated immune responses affects the ongoing evolution of rapidly evolving viruses such as HIV. By applying statistical approaches that account for phylogenetic relationships among viral sequences, we show that viral lineage effects rather than immune escape often explain apparent human leukocyte antigen (HLA)-mediated immune-escape mutations defined by older analysis methods. Phylogenetically informed methods identified immune-susceptible locations with greatly improved accuracy, and the associations we identified with these methods were experimentally validated. This approach has practical implications for understanding the impact of host immunity on pathogen evolution and for defining relevant variants for inclusion in vaccine antigens.