Magnesium administration is a common practice in cardiovascular surgeries utilizing cardiopulmonary bypass (CPB). However, concerns persist regarding the risk of hypermagnesemia, particularly in patients with kidney dysfunction. This study aims to determine the incidence of postoperative hypermagnesemia in CPB-assisted cardiovascular surgeries and identify the associated risk factors. This was a retrospective cohort study conducted at a tertiary medical center. Data from adult patients undergoing open-heart surgery utilizing CPB between 2018 and 2020 were analyzed. Sociodemographic, perioperative, and clinical variables were collected from electronic medical records. Logistic regression was utilized to identify independent risk factors for hypermagnesemia. Of 278 patients analyzed, 53.2% developed postoperative hypermagnesemia (Mg ≥2.5 mg/dL). Mild hypermagnesemia (Mg 2.5-3.9 mg/dL) was most common, with no significant impact on clinical outcomes observed. Patients with hypermagnesemia were older, with higher comorbidity burdens and lower baseline estimated glomerular filtration rate (eGFR). Cardioplegic solutions with higher magnesium content and lower baseline eGFR were independently associated with hypermagnesemia (OR 64.3; 95% CI 12.9-501.1 and OR 1.3; 95% CI, 1.1-1.5 respectively). Notably, ultrafiltration on CPB was associated with low risk of hypermagnesemia (OR 0.4, 95% CI 0.1-1.0, P value 0.048). This study highlights the importance of mindful magnesium supplementation strategies in those with advanced kidney disease. Future large-scale prospective multicenter studies should validate these findings and explore the extended effects of hypermagnesemia on clinical outcomes in patients with advanced CKD undergoing CPB surgeries.