Background: Doravirine is a novel non-nucleoside reverse transcriptase inhibitor (NNRTI) with a pharmacokinetic profile supporting once-daily dosing, and potent in-vitro activity against the most common NNRTI-resistant HIV-1 variants. We compared doravirine with ritonavir-boosted darunavir, when both were given with two nucleoside reverse transcriptase inhibitors (NRTIs), in adults with previously untreated HIV-1 infection. Methods: In this randomised, controlled, double-blind, multicentre, non-inferiority trial, adults with HIV-1 infection were screened and enrolled at 125 clinical centres in 15 countries. Eligible participants (aged ≥18 years) were naive to antiretroviral therapy with plasma HIV-1 RNA of at least 1000 copies per mL at screening. Participants who had previously been treated for a viral infection other than HIV-1, those taking immunosuppressive drugs, and individuals with active acute hepatitis were excluded. Participants were randomly assigned (1:1) via an interactive voice and web response system to receive oral doravirine 100 mg or darunavir 800 mg plus ritonavir 100 mg once daily, with two investigator-selected NRTIs (tenofovir and emtricitabine or abacavir and lamivudine) for up to 96 weeks. Randomisation was stratified by HIV-1 RNA measurements at screening (≤100 000 vs >100 000 copies per mL) and the NRTI pair. Study participants, funding institution staff, investigators, and study site personnel were masked to treatment group assignment. The primary efficacy endpoint was the proportion of participants achieving HIV-1 RNA of less than 50 copies per mL at week 48 defined by the US Food and Drug Administration snapshot algorithm, with non-inferiority established if the lower bound of the two-sided 95% CI for the treatment difference (doravirine minus darunavir) was greater than −10 percentage points. All participants who received at least one dose of study drug were included in the primary efficacy and safety analyses. This trial is active, but not recruiting, and is registered with ClinicalTrials.gov, number NCT02275780. Findings: Between Dec 1, 2014, and Oct 20, 2015, 1027 participants were screened for eligibility, of whom 769 participants were randomly assigned to treatment (385 with doravirine and 384 with ritonavir-boosted darunavir). 56 participants discontinued treatment in the doravirine group compared with 71 in the darunavir group, mostly due to loss to follow-up. 383 participants who received doravirine and 383 who received darunavir were included in the primary efficacy analyses. At week 48, 321 (84%) participants in the doravirine group and 306 (80%) in the darunavir group achieved plasma HIV-1 RNA of less than 50 copies per mL (difference 3·9%, 95% CI −1·6 to 9·4), indicating non-inferiority of the doravirine regimen. The most common study drug-related adverse events were diarrhoea (21 [5%] of 383 participants in the doravirine group and 49 [13%] of 383 participants in the darunavir group), nausea (25 [7%] vs 29 [8%]), and headache (23 [6%] vs ten [3%]). 18 participants (six [2%] of 383 participants in the doravirine group vs 12 [3%] of 383 participants in the darunavir group) discontinued treatment due to adverse events, which were considered drug-related in four (1%) participants in the doravirine group and 8 (2%) participants in the darunavir group. Serious adverse events occurred in 19 (5%) of 383 participants in the doravirine group and 23 (6%) of 383 in the darunavir roup, and were considered study-drug related in one (<1%) participant of each group. Interpretation: In treatment-naive adults with HIV-1 infection, doravirine combined with two NRTIs might offer a valuable treatment option for adults with previously untreated HIV-1 infection. Funding: Merck & Co.