Based on pre-clinical studies suggesting that magnesium (Mg) reduces cocaine self-administration and potentiates the antinociceptive effects of morphine, we conducted a preliminary randomized clinical trial investigating Mg for the treatment of illicit cocaine and opiate use. Eighteen methadone-maintained patients who used illicit opiates and cocaine received either Mg (732 mg/day) or placebo for 12 weeks. Overall, findings showed that the percentage of urine screens testing positive for opiates in the Mg group (22.6%) was half that of the placebo group (46.4%), p = .04; the difference was even greater in the "medication compliant" sample (Mg: 16.3%, placebo: 47.9%), p = .02. Cocaine craving was lower in the Mg compared to the placebo group, but there was no difference between groups in cocaine use. These preliminary findings suggest that Mg may have a beneficial effect for reducing illicit opiate use. It is possible that a higher dose of Mg than was used in this study may be needed to decrease cocaine use.