Type 2 diabetes mellitus (T2DM) is associated with increased morbidity and mortality due to the development of complications, especially due to poor glycemic control. Magnesium (Mg) is a crucial element in human health, and its deficiency plays a critical role in the development of lipid abnormalities and the initiation of diabetic complications. The study aimed to evaluate the correlation of hypomagnesemia (Mg) with the alteration of lipid profile patterns and investigate the adverse effects of glycemic control and body mass index (BMI) on magnesium levels among patients with T2DM. A total of 163 subjects whose ages ranged between 35-60 years for both sexes (males and females) were included in this study: 90 type II diabetic patients (40 males and 50 females) and 73 healthy individuals (34 males and 39 females) in Tripoli region, Western Libya. Blood glucose, HbA1c, Magnesium, and lipid profile parameters were biochemically estimated in the study along with the measurement of BMI. All the results were statistically analyzed using SPSS version 25 for applying one-way ANOVA and Person's correlation coefficient tests. The study revealed a significant decrease in serum magnesium levels (1.59 ± 0.47 mg/dL) in T2DM patients compared to the control group (2.21 ± 0.70 mg/dL) (p < 0.01). Significantly elevated levels of blood glucose (140.6 ± 30.95 mg/dL vs. 89.80 ± 12.62 mg/dL, p < 0.01), HbA1c (7.27 ± 2.62% vs. 5.32 ± 0.65%, p < 0.01), cholesterol, triglycerides and LDL cholesterol also observed in T2DM patients compared to healthy individuals. Conversely, HDL cholesterol levels were significantly lower in the T2DM group than in controls (24.44 ± 8.88 mg/dL vs. 47.06 ± 8.75 mg/dL, p < 0.01). There is a relationship between hypomagnesemia, glycemic control, and changed lipid profile in T2DM patients. Further, our results revealed a strong relationship between increased BMI and unfavorable alterations in all biochemical parameters examined.