Background Lopinavir–ritonavir has been proposed as a treatment for COVID-19 on the basis of in vitro activity, preclinical studies, and observational studies. Here, we report the results of a randomised trial to assess whether lopinavir–ritonavir improves outcomes in patients admitted to hospital with COVID-19. Methods In this randomised, controlled, open-label, platform trial, a range of possible treatments was compared with usual care in patients admitted to hospital with COVID-19. The trial is underway at 176 hospitals in the UK. Eligible and consenting patients were randomly allocated to either usual standard of care alone or usual standard of care plus lopinavir–ritonavir (400 mg and 100 mg, respectively) by mouth for 10 days or until discharge (or one of the other RECOVERY treatment groups: hydroxychloroquine, dexamethasone, or azithromycin) using web-based simple (unstratified) randomisation with allocation concealment. Randomisation to usual care was twice that of any of the active treatment groups (eg, 2:1 in favour of usual care if the patient was eligible for only one active group, 2:1:1 if the patient was eligible for two active groups). The primary outcome was 28-day all-cause mortality. Analyses were done on an intention-to-treat basis in all randomly assigned participants. The trial is registered with ISRCTN, 50189673, and ClinicalTrials.gov, NCT04381936. Findings Between March 19, 2020, and June 29, 2020, 1616 patients were randomly allocated to receive lopinavir– ritonavir and 3424 patients to receive usual care. Overall, 374 (23%) patients allocated to lopinavir–ritonavir and 767 (22%) patients allocated to usual care died within 28 days (rate ratio 1·03, 95% CI 0·91–1·17; p=0·60). Results were consistent across all prespecified subgroups of patients. We observed no significant difference in time until discharge alive from hospital (median 11 days [IQR 5 to >28] in both groups) or the proportion of patients discharged from hospital alive within 28 days (rate ratio 0·98, 95% CI 0·91–1·05; p=0·53). Among patients not on invasive mechanical ventilation at baseline, there was no significant difference in the proportion who met the composite endpoint of invasive mechanical ventilation or death (risk ratio 1·09, 95% CI 0·99–1·20; p=0·092). Interpretation In patients admitted to hospital with COVID-19, lopinavir–ritonavir was not associated with reductions in 28-day mortality, duration of hospital stay, or risk of progressing to invasive mechanical ventilation or death. These findings do not support the use of lopinavir–ritonavir for treatment of patients admitted to hospital with COVID-19.