Background and Objectives: Mechanism studies have indicated that magnesium (Mg) and calcium (Ca) had important biological functions in glucose regulation, but epidemiological data on their associations with glycosylated hemoglobin (HbA1c) are sparse. We aimed to explore the associations of Mg and Ca with abnormal HbA1c, and examined the mediating effects of inflammation in coronary artery disease (CAD) Chinese adults. Methods and Study Design: A hospital–based cross–sectional study of 11934 patients with CAD was conducted. Serum Mg and Ca concentrations were measured. Results: In multivariable analyses, Mg and Mg/Ca ratio were inversely associated with abnormal HbA1c (Q4 vs Q1: ORMg: 0.61, 95% CIMg: 0.53, 0.71; ORMg/Ca ratio: 0.67, 95% CIMg/Ca ratio: 0.54, 0.84). However, null association of Ca with abnormal HbA1c was shown (Q4 vs Q1: OR: 1.15, 95% CI: 0.92, 1.44). Serum Mg and Mg/Ca ratio were inversely associated with abnormal fasting blood glucose (FBG). In contrast, serum Ca was positively associated with abnormal FBG. Path analysis indicated that there were no mediating effects of hypersensitivity C reactive protein (hsCRP) on Mg and Mg/Ca-abnormal HbA1c associations. Conclusions: Our study suggested that serum Mg and Mg/Ca ratio were inversely associated with abnormal HbA1c in Chinese adults with CAD. The Mg-abnormal HbA1c relationship might not be mediated by hsCRP.