Diabetes mellitus is characterized by poor glycemic control, as indicated by circulating levels of glycosylated hemoglobin A1c (HbA1c). Recent reports have implicated vitamin B12 deficiency in worsening glycemic control, leading to complications like neuropathy and anemia. We aimed to assess the association between vitamin B12 deficiency and elevated HbA1c levels in patients with diabetes. Data collected from a cohort of 364 patients with diabetes encompassed circulating levels of HbA1c, vitamin B12, age, and sex. Participants included 202 women (55.5%) and 162 men (44.5%) and were classified by age (≤60 years and >60 years) and sex. The statistical methods employed included Pearson’s correlation, Welch’s t-test, and the Chi-square test via RStudio software. Our findings revealed that the mean HbA1c percentage is significantly lower in patients with vitamin B12 deficiency compared with their non-deficient counterparts (2.5 ± 0.58 versus 2.8 ± 0.64, respectively; p = 0.000). Further, the correlation between vitamin B12 and HbA1c levels demonstrates a weakly positive relationship (r = 0.22), which is statistically significant (p < 0.001). The prevalence of vitamin B12 deficiency is consistent across both age groups (12.68% of patients aged ≤60 years and 11.25% of those >60 years). Our data suggests a significant but negative correlation between vitamin B12 deficiency and HbA1c levels in patients with diabetes. The observed correlation between vitamin B12 deficiency and improved glycemic control warrants further investigation and may enhance the management of patients with diabetes.