Antiretroviral therapy (ART) during pregnancy is important for both maternal health and prevention of perinatal HIV-1 transmission; however adequate data on the safety and efficacy of different ART regimens that are likely to be used by pregnant women are scarce. In this trial we compared the safety and efficacy of three antiretroviral regimens started in pregnancy: dolutegravir, emtricitabine, and tenofovir alafenamide fumarate; dolutegravir, emtricitabine, and tenofovir disoproxil fumarate; and efavirenz, emtricitabine, and tenofovir disoproxil fumarate. This multicentre, open-label, randomised controlled, phase 3 trial was done at 22 clinical research sites in nine countries (Botswana, Brazil, India, South Africa, Tanzania, Thailand, Uganda, the USA, and Zimbabwe). Pregnant women (aged ≥18 years) with confirmed HIV-1 infection and at 14-28 weeks' gestation were eligible. Women who had previously taken antiretrovirals in the past were excluded (up to 14 days of ART during the current pregnancy was permitted), as were women known to be pregnant with multiple fetuses, or those with known fetal anomaly or a history of psychiatric illness. Participants were randomly assigned (1:1:1) using a central computerised randomisation system. Randomisation was done using permuted blocks (size six) stratified by gestational age (14-18, 19-23, and 24-28 weeks' gestation) and country. Participants were randomly assigned to receive either once-daily oral dolutegravir 50 mg, and once-daily oral fixed-dose combination emtricitabine 200 mg and tenofovir alafenamide fumarate 25 mg; once-daily oral dolutegravir 50 mg, and once-daily oral fixed-dose combination emtricitabine 200 mg and tenofovir disoproxil fumarate 300 mg; or once-daily oral fixed-dose combination of efavirenz 600 mg, emtricitabine 200 mg, and tenofovir disoproxil fumarate 300 mg. The primary efficacy outcome was the proportion of participants with viral suppression, defined as an HIV-1 RNA concentration of less than 200 copies per mL, at or within 14 days of delivery, assessed in all participants with an HIV-1 RNA result available from the delivery visit, with a prespecified non-inferiority margin of -10% in the combined dolutegravir-containing groups versus the efavirenz-containing group (superiority was tested in a pre-planned secondary analysis). Primary safety outcomes, compared pairwise among treatment groups, were the occurrence of a composite adverse pregnancy outcome (ie, either preterm delivery, the infant being born small for gestational age, stillbirth, or spontaneous abortion) in all participants with a pregnancy outcome, and the occurrence of grade 3 or higher maternal and infant adverse events in all randomised participants. This trial was registered with ClinicalTrials.gov, NCT03048422. Between Jan 19, 2018, and Feb 8, 2019, we enrolled and randomly assigned 643 pregnant women: 217 to the dolutegravir, emtricitabine, and tenofovir alafenamide fumarate group, 215 to the dolutegravir, emtricitabine, and tenofovir disoproxil fumarate group, and 211 to the efavirenz, emtricitabine, and tenofovir disoproxil fumarate group. At enrolment, median gestational age was 21·9 weeks (IQR 18·3-25·3), the median HIV-1 RNA concentration among participants was 902·5 copies per mL (152·0-5182·5; 181 [28%] of 643 participants had HIV-1 RNA concentrations of <200 copies per mL), and the median CD4 count was 466 cells per μL (308-624). HIV-1 RNA concentrations at delivery were available for 605 (94%) participants. Of these, 395 (98%) of 405 participants in the combined dolutegravir-containing groups had viral suppression at delivery compared with 182 (91%) of 200 participants in the efavirenz, emtricitabine, and tenofovir disoproxil fumarate group (estimated difference 6·5% [95% CI 2·0 to 10·7], p=0·0052; excluding the non-inferiority margin of -10%). Significantly fewer participants in the dolutegravir, emtricitabine, and tenofovir alafenamide fumarate group (52 [24%] of 216) had a composite adverse pregnancy outcome than those in the dolutegravir, emtricitabine, and tenofovir disoproxil fumarate group (70 [33%] of 213; estimated difference -8·8% [95% CI -17·3 to -0·3], p=0·043) or the efavirenz, emtricitabine, and tenofovir disoproxil fumarate group (69 [33%] of 211; -8·6% [-17·1 to -0·1], p=0·047). The proportion of participants or infants with grade 3 or higher adverse events did not differ among the three groups. The proportion of participants who had a preterm delivery was significantly lower in the dolutegravir, emtricitabine, and tenofovir alafenamide fumarate group (12 [6%] of 208) than in the efavirenz, emtricitabine, and tenofovir disoproxil fumarate group (25 [12%] of 207; -6·3% [-11·8 to -0·9], p=0·023). Neonatal mortality was significantly higher in the efavirenz, emtricitabine, and tenofovir disoproxil fumarate group (ten [5%] of 207 infants) than in the dolutegravir, emtricitabine, and tenofovir alafenamide fumarate group (two [1%] of 208; p=0·019) or the dolutegravir, emtricitabine, and tenofovir disoproxil fumarate group (three [2%] of 202; p=0·050). When started in pregnancy, dolutegravir-containing regimens had superior virological efficacy at delivery compared with the efavirenz, emtricitabine, and tenofovir disoproxil fumarate regimen. The dolutegravir, emtricitabine, and tenofovir alafenamide fumarate regimen had the lowest frequency of composite adverse pregnancy outcomes and of neonatal deaths. National Institute of Allergy and Infectious Diseases, the Eunice Kennedy Shriver National Institute of Child Health and Human Development, and the National Institute of Mental Health.