Postoperative urinary retention (POUR) is a common complication after total knee arthroplasty. Currently, there are no clinical data regarding the effects of magnesium sulfate on POUR. Here, we investigated the effects of intraoperative magnesium sulfate infusion in patients with POUR following total knee arthroplasty. We reviewed the medical records of patients who underwent elective unilateral total knee arthroplasty under spinal anesthesia between June 2016 and May 2018. The patients were grouped based on whether they were treated with magnesium (magnesium group) or not (control group). We investigated the incidence of POUR and the postoperative analgesic requirement. Totally, 483 patients were included in the analysis. After propensity score matching with the control group, the magnesium group showed a lower incidence of POUR (odds ratio, 0.49; 95% CI, 0.29–0.83; p = 0.011) and lesser opioid consumption (p = 0.049) than the control group. Multivariate logistic regression analysis revealed that intraoperative continuous infusion of magnesium (p = 0.008) and age (p = 0.001) were significantly related to the incidence of POUR. This retrospective observational study demonstrated that administration of magnesium sulfate was associated with a lower incidence of POUR following total knee arthroplasty.