Background Magnesium is neuroprotective in animal models of stroke, and findings of small clinical pilot trials suggest potential benefit in people. We aimed to test whether intravenous magnesium sulphate, given within 12 h of stroke onset, reduces death or disability at 90 days. Methods 2589 patients were randomised within 12 h of acute stroke to receive 16 mmol MgSO4 intravenously over 15 min and then 65 mmol over 24 h, or matching placebo. Primary outcome was a global endpoint statistic expressed as the common odds ratio for death or disability at day 90. Secondary outcomes were mortality and death or disability, variously defined as Barthel score less than 95, Barthel score less than 60, and modified Rankin scale more than 1. Predefined subgroup analyses were for the primary endpoint in patients in whom treatment commenced within 6 h versus after 6 h, ischaemic versus non-ischaemic strokes, and cortical stroke syndromes versus non-cortical strokes. Intention-to-treat and efficacy analyses were done. Findings The efficacy dataset included 2386 patients. Primary outcome was not improved by magnesium (odds ratio 0.95, 95% CI 0.80-1.13, p=0.59). Mortality was slightly higher in the magnesium-treated group than in the placebo group (hazard ratio 1.18, 95% CI 0.97-1.42, p=0.098). Secondary outcomes did not show any treatment effect. Planned subgroup analyses showed benefit of magnesium in non-cortical strokes (p=0.011) whereas greater benefit had been expected in the cortical group. Interpretation Magnesium given within 12 h of acute stroke does not reduce the chances of death or disability significantly, although it may be of benefit in lacunar strokes.