The study design is an open-label, randomized controlled trial. The study will be conducted at study sites in Uganda and South Africa. The study population will include HIV-infected patients on first-line antiretroviral therapy with a recent viral load >1,000 copies/milliliter (or dried blood spot viral load >1,000 copies/milliliter). Eligible participants will be randomized to the WHO-based standard of care for management of virologic failure or immediate resistance testing to guide ART regimen decisions. The primary outcome of interest will be viral suppression (<200 copies/mL) at 9 months after study enrollment, and will be assessed using an intention to treat analysis, where missing or absent results will be considered failures. Secondary outcomes of interest will be viral suppression below the limit of assay detection, viral suppression on continuation of first-line (non-nucleoside reverse transcriptase inhibitor [NNRTI]-based) therapy, drug resistance at study conclusion, and mortality, among others. The overarching goal of this study is to determine whether addition of routine resistance testing, to guide management of virologic failure and sustain the successful completion of the HIV continuum of care, improves clinical outcomes and reduces costs for patients with virologic failure on first-line therapy in sub-Saharan Africa.