Vascular calcification, a common complication in patients with chronic kidney disease, involves a variety of mechanisms associated with the regulation of calcification-associated factors. Previous clinical studies have indicated that magnesium is involved in the reduction of vascular calcification; however, the mechanism underlying this process remains unknown. The aim of the present study was to investigate the effects of magnesium on β-glycerophosphate (β-GP)-induced calcification and the underlying mechanisms. Primary rat vascular smooth muscle cells (VSMCs) were exposed to 10 mM β-GP in medium with or without the addition of 3 mM magnesium or 2-aminoethoxy-diphenylborate (2-APB; an inhibitor of magnesium transport), for a 14-day period. Calcium deposition and alkaline phosphatase (ALP) activity were measured by Alizarin red staining, quantification of calcium and enzyme-linked immunosorbent assay. The expression levels of core-binding factor α-1 (Cbfα1), matrix Gla protein (MGP) and osteopontin (OPN) were determined by reverse transcription-polymerase chain reaction or western blot analysis, following incubation for 0, 3, 6, 10 and 14 days with the different media. VSMC calcification and ALP activity was reduced significantly in the high-magnesium medium compared with the calcification medium, during the 14-day incubation. The magnesium-induced changes in the VSMCs included a β-GP-induced downregulation of Cbfα1 by day 3 of incubation, an effect that was gradually enhanced over the 14-day period. By contrast, magnesium produced notable increases in MGP and OPN expression levels, with an opposite pattern to that observed in the Cbfα1 expression levels. However, the addition of 2-APB appeared to inhibit the protective effect of magnesium on the VSMCs. Therefore, magnesium was able to effectively reduce β-GP-induced calcification in rat VSMCs by regulating the expression levels of calcification-associated factors in a time-dependent manner.