The underlying mechanisms driving the evolution of drug resistance in human immunodeficiency virus (HIV) are only partially understood. We investigated the evolutionary cost of the major resistance mutations in HIV-1 protease in terms of protein stability. The accumulation of resistance mutations destabilizes the protease, limiting further adaptation. From an analysis of clinical isolates, we identified specific accessory mutations that were able to restore the stability of the protease or even increase it beyond the wild-type baseline. Resistance mutations were also found to decrease the activity of HIV protease near neutral pH values, while incorporating stabilizing mutations improved the enzyme's pH tolerance. These findings help us to explain the prevalence of mutations located far from the active site and underscore the importance of protein stability during the evolution of drug resistance in HIV.