Background. Dolutegravir is now recommended for second-line anti-retroviral therapy (ART) in low- and middle-income countries. We compared outcomes with dolutegravir (DTG) versus the previous lopinavir/ritonavir (LPV/r) regimen in South Africa. Methods. We used routinely collected, de-identified data from 59 South African clinics. We included people living with HIV aged ≥ 15 years with virologic failure (two consecutive viral loads ≥1000 copies/mL) on first-line tenofovir disoproxil fumarate (TDF)-based ART and switched to second-line ART. We used modified Poisson regression models to compare outcomes of 12-month retention-in-care and viral suppression (<50 copies/ml) after switching to second-line regimens of zidovudine (AZT), emtricitabine/lamivudine (XTC), DTG and TDF/XTC/DTG and AZT/XTC/LPV/r. Findings. Of 1214 participants, 729 (60.0%) were female, median age was 36 years (interquartile range 30 to 42), 689 (56.8%) were switched to AZT/XTC/LPV/r, 217 (17.9%) to AZT/XTC/DTG and 308 (25.4%) to TDF/XTC/DTG. Retention-in-care was higher with AZT/XTC/DTG (85.7%, adjusted risk ratio (aRR) 1.14, 95% confidence interval (CI) 1.03 to 1.27; adjusted risk difference (aRD) 10.89%, 95%CI 2.01 to 19.78) but not different with TDF/XTC/DTG (76.9%, aRR 1.01, 95%CI 0.94 to 1.10; aRD 1.04%, 95%CI -5.03 to 7.12) compared to AZT/XTC/LPV/r (75.2%). Retention-in-care with TDF/XTC/DTG was not statistically significantly different from AZT/XTC/DTG (aRR 0.89, 95%CI 0.78 to 1.01; aRD -9.85%, 95%CI -20.33 to 0.63). Of 799 participants who were retained-in-care with a 12-month viral load, viral suppression was higher with AZT/XTC/DTG (59.3%, aRR 1.25, 95%CI 1.06 to 1.47; aRD 11.57%, 95%CI 2.37 to 20.76) and TDF/XTC/DTG (60.7%, aRR 1.30, 95%CI 1.14 to 1.48; aRD 14.16%, 95%CI 7.14 to 21.18) than with the AZT/XTC/LPV/r regimen (46.7%). Interpretation. DTG-based second-line regimens were associated with similar or better retention-in-care and better viral suppression than the LPV/r-based regimen. TDF/XTC/DTG had similar viral suppression compared to AZT/XTC/DTG.