Supplemental O2 is not always available at health facilities in low-income and middle-income countries (LMICs). Solar-powered O2 delivery can overcome gaps in O2 access, generating O2 independent of grid electricity. We hypothesized that installation of solar-powered O2 systems on the paediatrics ward of rural Ugandan hospitals would lead to a reduction in mortality among hypoxaemic children. In this pragmatic, country-wide, stepped-wedge, cluster randomised controlled trial, solar-powered O2 systems (ie, photovoltaic cells, battery bank, and O2 concentrator) were sequentially installed at 20 rural health facilities in Uganda. Sites were selected for inclusion based on the following criteria: District Hospital or Health Centre IV with paediatric inpatient services; supplemental O2 on the paediatric ward was not available or was unreliable; and adequate space to install solar panels, a battery bank, and electrical wiring. Allocation concealment was achieved for sites up to 2 weeks before installation, but the study was not masked overall. Children younger than 5 years admitted to hospital with hypoxaemia and respiratory signs were included. The primary outcome was mortality within 48 h of detection of hypoxaemia. The statistical analysis used a linear mixed effects logistic regression model accounting for cluster as random effect and calendar time as fixed effect. The trial is registered at ClinicalTrials.gov, NCT03851783. Between June 28, 2019, and Nov 30, 2021, 2409 children were enrolled across 20 hospitals and, after exclusions, 2405 children were analysed. 964 children were enrolled before site randomisation and 1441 children were enrolled after site randomisation (intention to treat). There were 104 deaths, 91 of which occurred within 48 h of detection of hypoxaemia. The 48 h mortality was 49 (5·1%) of 964 children before randomisation and 42 (2·9%) of 1440 (one individual did not have vital status documented at 48 h) after randomisation (adjusted odds ratio 0·50, 95% CI 0·27-0·91, p=0·023). Results were sensitive to alternative parameterisations of the secular trend. There was a relative risk reduction of 48·7% (95% CI 8·5-71·5), and a number needed to treat with solar-powered O2 of 45 (95% CI 28-230) to save one life. Use of O2 increased from 484 (50·2%) of 964 children before randomisation to 1424 (98·8%) of 1441 children after randomisation (p<0·0001). Adverse events were similar before and after randomisation and were not considered to be related to the intervention. The estimated cost-effectiveness was US$25 (6-505) per disability-adjusted life-year saved. This stepped-wedge, cluster randomised controlled trial shows the mortality benefit of improving O2 access with solar-powered O2. This study could serve as a model for scale-up of solar-powered O2 as one solution to O2 insecurity in LMICs. Grand Challenges Canada and The Women and Children's Health Research Institute.