The objective of this study was to assess the association of in-hospital mortality risk based on change in serum magnesium levels in hospitalised patients. All adult patients admitted to our hospital from years 2009 to 2013 with at least two serum magnesium measurements during hospitalisation were included. Serum magnesium change, defined as the absolute difference between the highest and lowest serum magnesium, was categorised into six groups: 0–0.2, 0.3–0.4, 0.5–0.6, 0.7–0.8, 0.9–1.0, ≥1.1 mg/dL. In-hospital mortality was the outcome of interest. Logistic regression was used to assess the association between serum magnesium change and in-hospital mortality, using serum magnesium change of 0.0–0.2 mg/dL as the reference group. A total of 42 141 patients, with the median serum magnesium change during hospital stay of 0.3 (IQR 0.2–0.6) mg/dL, were studied. In-hospital mortality based on serum magnesium change of 0–0.2, 0.3–0.4, 0.5–0.6, 0.7–0.8, 0.9–1.0, ≥1.1 mg/dL was 1.3%, 2.3%, 3.1%, 5.0%, 6.5%, and 8.8%, respectively (p<0.001). After adjustment for potential confounders, increased serum magnesium change was significantly associated with higher in-hospital mortality with adjusted OR of 1.39 (95% 1.14–1.69) in serum magnesium change of 0.3–0.4, 1.48 (95% CI 1.21 to 1.81) in 0.5–0.6, 1.89 (95% CI 1.53 to 2.34) in 0.7–0.8, 1.85 (95% CI 1.45 to 2.37) in 0.9–1.0 and 1.89 (95% CI 1.48 to 2.41) in ≥1.1 mg/dL when compared with serum magnesium change group of 0–0.2 mg/dL. Increased in-hospital mortality was associated with both downward and upward trends of serum magnesium change during hospitalisation. The greater extent of change in serum magnesium levels was progressively associated with increased in-hospital mortality