Background: Azithromycin has been proposed as a treatment for COVID-19 on the basis of its immunomodulatory actions. We aimed to evaluate the safety and efficacy of azithromycin in patients admitted to hospital with COVID-19. Methods: In this randomised, controlled, open-label, adaptive platform trial (Randomised Evaluation of COVID-19 Therapy [RECOVERY]), several possible treatments were compared with usual care in patients admitted to hospital with COVID-19 in the UK. 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 azithromycin 500 mg once per day by mouth or intravenously for 10 days or until discharge (or allocation to one of the other RECOVERY treatment groups). Patients were assigned via web-based simple (unstratified) randomisation with allocation concealment and were twice as likely to be randomly assigned to usual care than to any of the active treatment groups. Participants and local study staff were not masked to the allocated treatment, but all others involved in the trial were masked to the outcome data during the trial. The primary outcome was 28-day all-cause mortality, assessed in the intention-to-treat population. The trial is registered with ISRCTN, 50189673, and ClinicalTrials.gov, NCT04381936. Findings: Between April 7 and Nov 27, 2020, of 16 442 patients enrolled in the RECOVERY trial, 9433 (57%) were eligible and 7763 were included in the assessment of azithromycin. The mean age of these study participants was 65·3 years (SD 15·7) and approximately a third were women (2944 [38%] of 7763). 2582 patients were randomly allocated to receive azithromycin and 5181 patients were randomly allocated to usual care alone. Overall, 561 (22%) patients allocated to azithromycin and 1162 (22%) patients allocated to usual care died within 28 days (rate ratio 0·97, 95% CI 0·87–1·07; p=0·50). No significant difference was seen in duration of hospital stay (median 10 days [IQR 5 to >28] vs 11 days [5 to >28]) or the proportion of patients discharged from hospital alive within 28 days (rate ratio 1·04, 95% CI 0·98–1·10; p=0·19). Among those not on invasive mechanical ventilation at baseline, no significant difference was seen in the proportion meeting the composite endpoint of invasive mechanical ventilation or death (risk ratio 0·95, 95% CI 0·87–1·03; p=0·24). Interpretation: In patients admitted to hospital with COVID-19, azithromycin did not improve survival or other prespecified clinical outcomes. Azithromycin use in patients admitted to hospital with COVID-19 should be restricted to patients in whom there is a clear antimicrobial indication. Funding: UK Research and Innovation (Medical Research Council) and National Institute of Health Research.