Purpose To investigate whether magnesium oxide during external-beam radiotherapy for prostate cancer reduces intrafraction prostate motion in a double-blind, placebo-controlled randomized trial. Methods and Materials At the Department of Radiotherapy, prostate cancer patients scheduled for intensity-modulated radiotherapy (77 Gy in 35 fractions) using fiducial marker–based position verification were randomly assigned to receive magnesium oxide (500 mg twice a day) or placebo during radiotherapy. The primary outcome was the proportion of patients with clinically relevant intrafraction prostate motion, defined as the proportion of patients who demonstrated in ≥50% of the fractions an intrafraction motion outside a range of 2 mm. Secondary outcome measures included quality of life and acute toxicity. Results In total, 46 patients per treatment arm were enrolled. The primary endpoint did not show a statistically significant difference between the treatment arms with a percentage of patients with clinically relevant intrafraction motion of 83% in the magnesium oxide arm as compared with 80% in the placebo arm (p = 1.00). Concerning the secondary endpoints, exploratory analyses demonstrated a trend towards worsened quality of life and slightly more toxicity in the magnesium oxide arm than in the placebo arm; however, these differences were not statistically significant. Conclusions Magnesium oxide is not effective in reducing the intrafraction prostate motion during external-beam radiotherapy, and therefore there is no indication to use it in clinical practice for this purpose.