BACKGROUND: The primary analysis of the FLAMINGO study at 48 weeks showed that patients taking dolutegravir once daily had a significantly higher virological response rate than did those taking ritonavir-boosted darunavir once daily, with similar tolerability. We present secondary efficacy and safety results analysed at 96 weeks. METHODS: FLAMINGO was a multicentre, open-label, phase 3b, non-inferiority study of HIV-1-infected treatment-naive adults. Patients were randomly assigned (1:1) to dolutegravir 50 mg or darunavir 800 mg plus ritonavir 100 mg, with investigator-selected combination tenofovir and emtricitabine or combination abacavir and lamivudine background treatment. The main endpoints were plasma HIV-1 RNA less than 50 copies per mL and safety. The non-inferiority margin was -12%. If the lower end of the 95% CI was greater than 0%, then we concluded that dolutegravir was superior to ritonavir-boosted darunavir. This trial is registered with ClinicalTrials.gov, number NCT01449929. FINDINGS: Of 595 patients screened, 488 were randomly assigned and 484 included in the analysis (242 assigned to receive dolutegravir and 242 assigned to receive ritonavir-boosted darunavir). At 96 weeks, 194 (80%) of 242 patients in the dolutegravir group and 164 (68%) of 242 in the ritonavir-boosted darunavir group had HIV-1 RNA less than 50 copies per mL (adjusted difference 12·4, 95% CI 4·7-20·2; p=0·002), with the greatest difference in patients with high viral load at baseline (50/61 [82%] vs 32/61 [52%], homogeneity test p=0·014). Six participants (three since 48 weeks) in the dolutegravir group and 13 (four) in the darunavir plus ritonavir group discontinued because of adverse events. The most common drug-related adverse events were diarrhoea (23/242 [10%] in the dolutegravir group vs 57/242 [24%] in the darunavir plus ritonavir group), nausea (31/242 [13%] vs 34/242 [14%]), and headache (17/242 [7%] vs 12/242 [5%]). INTERPRETATION: Once-daily dolutegravir is associated with a higher virological response rate than is once-daily ritonavir-boosted darunavir. Dolutegravir compares favourably in efficacy and safety to a boosted darunavir regimen with nucleoside reverse transcriptase inhibitor background treatment for HIV-1-infected treatment-naive patients. FUNDING: ViiV Healthcare and Shionogi & Co.