In this work a confocal Raman microspectrometer is used to investigate the influence of Na+ and Mg2+ ions on the DNA structural changes induced by low pH. Measurements are carried out on calf thymus DNA at neutral pH (7) and pH 3 in the presence of low and high concentrations of Na+ and Mg2+ ions, respectively. It is found that low concentrations of Na+ ions do not protect DNA against binding of H+. High concentrations of monovalent ions can prevent protonation of the DNA double helix. Our Raman spectra show that low concentrations of Mg2+ ions partly protect DNA against protonation of cytosine (line at 1262 cm-1) but do not protect adenine and guanine N(7) against binding of H+ (characteristic lines at 1304 and 1488 cm-1, respectively). High concentrations of Mg2+ can prevent protonation of cytosine and protonation of adenine (disruption of AT pairs). By analyzing the line at 1488 cm-1, which obtains most of its intensity from a guanine vibration, high magnesium salt protect the N(7) of guanine against protonation. A high salt concentration can prevent protonation of guanine, cytosine, and adenine in DNA. Higher salt concentrations cause less DNA protonation than lower salt concentrations. Magnesium ions are found to be more effective in protecting DNA against binding of H+ as compared with calcium ions presented in a previous study. Divalent metal cations (Mg2+, Ca2+) are more effective in protecting DNA against protonation than monovalent ions (Na+).