© 2018 Elsevier Ltd Background: Implementation of ultrasensitive HIV drug resistance tests for routine clinical use is hampered by uncertainty about the clinical relevance of drug-resistant minority variants. We assessed different detection thresholds for pretreatment drug resistance to predict an increased risk of virological failure. Methods: We did a case-control study nested within a prospective multicountry cohort. Our study included patients from 12 clinical sites in Kenya, Nigeria, South Africa, Uganda, and Zambia. We defined cases as patients with virological failure (ie, those who had either viral load ≥400 copies per mL at 12 months or had switched to second-line antiretroviral therapy [ART] as a result of virological failure before 12 months) and controls as those with viral suppression (viral load <400 copies per mL at 12 months) on first-line non-nucleoside reverse transcriptase inhibitor-based antiretroviral therapy. We assessed pretreatment drug resistance with Illumina MiSeq next-generation sequencing, using the International Antiviral Society (IAS)-USA mutation list or the Stanford HIV Drug Resistance Database (HIVDB) genotypic sensitivity score. We calculated diagnostic accuracy measures and assessed the odds of virological failure using conditional logistic regression for 1%, 5%, and 10% pretreatment drug resistance detection thresholds, compared with the conventional 20% or more used in Sanger-based sequencing. Findings: Paired viral load results before ART and at month 12 of follow-up were available from 1896 participants. We identified 178 patients with virological failure and selected 338 matched controls. We excluded 117 patients from pretreatment drug resistance analysis; therefore, 152 cases of virological failure and 247 controls were included in the final analysis. With the IAS-USA mutation list, at a detection threshold of 20% or more in patients with pretreatment drug resistance, the adjusted odds ratio (OR) for virological failure was 9·2 (95% CI 4·2–20·1) compared with those without pretreatment drug resistance. Lowering the threshold resulted in adjusted ORs of virological failure of 6·8 (95% CI 3·3–13·9) at the 10% threshold, 7·6 (3·4–17·1) at the 5% threshold, and 4·5 (2·0–10·2) at the 1% threshold. Lowering the detection threshold from 20% improved the sensitivity (ie, ability to identify cases) from 12% (n=18) to 13% (n=19) at detection threshold 10%, to 15% (n=23) at detection threshold 5%, and to 17% (n=26) at detection threshold 1%, but caused a slight reduction in specificity (ie, ability to identify controls) from 98% (n=241) to 96% (n=238) at the 10% threshold, 96% (n=236) at the 5% threshold, and a larger reduction to 92% (n=227) at the 1% threshold. Diagnostic ORs were 5·4 (95% CI 2·1–13·9) at the 20% threshold, 3·8 (1·7–8·6) at the 10% threshold, 3·8 (1·8–8·1) at the 5% threshold, and 2·3 (1·2–4·2) at the 1% threshold. Use of the Stanford HIVDB genotypic sensitivity scores yielded similar ORs for virological failure, sensitivities, specificities, and diagnostic ORs. Interpretation: Ultrasensitive resistance testing for pretreatment drug resistance improved identification of people at risk of virological failure; however, this came with a reduction in our ability to identify people with viral suppression, especially at very low thresholds. Further modelling is needed to estimate the optimal trade-off for the 5% and 20% thresholds, balancing improved case finding against unnecessary regimen switching. Funding: The Netherlands Ministry of Foreign Affairs, IrsiCaixa, and European Union.