Coagulopathy is associated with poor prognosis of traumatic brain injury (TBI) patients. This study is performed to explore the association between serum magnesium level and the risk of coagulopathy in TBI. TBI patients from the Medical Information Mart for Intensive Care-III database were included for this study. Logistic regression analysis was performed to explore risk factors and develop a predictive model for coagulopathy in TBI. The restricted cubic spline (RCS) was utilized to analyze the association between serum magnesium level and the development of coagulopathy. Receiver operating characteristic curve was drawn to evaluate the performance of the predictive model for coagulopathy. The incidence of coagulopathy in TBI was 32.6%. The RCS indicated the association between magnesium and coagulopathy was U-shaped. Multivariate logistic regression confirmed age, coronary heart disease, cerebral vascular disease, chronic liver disease, GCS, ISS, epidural hematoma, hemoglobin, shock index and magnesium level were independently associated with the coagulopathy in TBI. Compared with patients of magnesium level between 1.7 and 2.3 mg/dL, those with magnesium level below 1.7 mg/dL or above 2.2 mg/dL had a higher risk of coagulopathy. Both hypermagnesemia and hypomagnesemia are associated with higher risk of coagulopathy in TBI patients. Physicians should pay more attention on preventing coagulopathy in TBI patients with hypomagnesemia or hypermagnesemia.