Background There is no proven specific pharmacological treatment for patients with the acute respiratory distress syndrome (ARDS). The efficacy of corticosteroids in ARDS remains controversial. We aimed to assess the effects of dexamethasone in ARDS, which might change pulmonary and systemic inflammation and result in a decrease in duration of mechanical ventilation and mortality. Methods We did a multicentre, randomised controlled trial in a network of 17 intensive care units (ICUs) in teaching hospitals across Spain in patients with established moderate-to-severe ARDS (defined by a ratio of partial pressure of arterial oxygen to the fraction of inspired oxygen of 200 mm Hg or less assessed with a positive end-expiratory pressure of 10 cm H2O or more and FiO2 of 0·5 or more at 24 h after ARDS onset). Patients with brain death, terminal-stage disease, or receiving corticosteroids or immunosuppressive drugs were excluded. Eligible patients were randomly assigned based on balanced treatment assignments with a computerised randomisation allocation sequence using blocks of 10 opaque, sealed envelopes to receive immediate treatment with dexamethasone or continued routine intensive care (control group). Patients in the dexamethasone group received an intravenous dose of 20 mg once daily from day 1 to day 5, which was reduced to 10 mg once daily from day 6 to day 10. Patients in both groups were ventilated with lung-protective mechanical ventilation. Allocation concealment was maintained at all sites during the trial. Primary outcome was the number of ventilator-free days at 28 days, defined as the number of days alive and free from mechanical ventilation from day of randomisation to day 28. Secondary outcome was all-cause mortality 60 days after randomisation. All analyses were done according to the intention-to-treat principle. This study is registered with ClinicalTrials.gov, NCT01731795. Findings Between March 28, 2013, and Dec 31, 2018, we enrolled 277 patients and randomly assigned 139 patients to the dexamethasone group and 138 to the control group. The trial was stopped by the data safety monitoring board due to low enrolment rate after enrolling more than 88% (277/314) of the planned sample size. The mean number of ventilator-free days was higher in the dexamethasone group than in the control group (between-group difference 4·8 days [95% CI 2·57 to 7·03]; p<0·0001). At 60 days, 29 (21%) patients in the dexamethasone group and 50 (36%) patients in the control group had died (between-group difference −15·3% [–25·9 to −4·9]; p=0·0047). The proportion of adverse events did not differ significantly between the dexamethasone group and control group. The most common adverse events were hyperglycaemia in the ICU (105 [76%] patients in the dexamethasone group vs 97 [70%] patients in the control group), new infections in the ICU (eg, pneumonia or sepsis; 33 [24%] vs 35 [25%]), and barotrauma (14 [10%] vs 10 [7%]). Interpretation Early administration of dexamethasone could reduce duration of mechanical ventilation and overall mortality in patients with established moderate-to-severe ARDS. Funding Fundación Mutua Madrileña, Instituto de Salud Carlos III, The European Regional Development's Funds, Asociación CientÃfica Pulmón y Ventilación Mecánica.