Genetic variation in CLDN19, CNNM2, FXYD2, SLC41A2, and TRPM6 significantly influenced diabetes risk (p < 0.05), and for CNNM2, FXYD2, SLC41A2 and TRPM6 this risk was completely mediated by serum magnesium levels. The gene discussed is SLC41A2; the disease is diabetes mellitus.