Magnesium plays an important role in tons of bodily functions: metabolism, blood sugar regulation, bone health, and nerve and muscle function, among other things. And, no surprise, it plays a crucial role in sleep, too.

According to some evidence, yes, confirms W. Christopher Winter, M.D., author of The Sleep Solution and a board-certified sleep specialist at Charlottesville Neurology and Sleep Medicine in Virginia.

For one, magnesium is an important player in many of the steps that allow you to take protein and convert it into the chemicals that help you feel sleepy, explains Dr. Winter. It also helps calm the nervous system down, helping it work more efficiently, and plays a role in muscle relaxation and nerve function, he says. (That’s why magnesium is often a supplement docs use to help people with managing symptoms of restless leg syndrome, says Dr. Winter.)

Magnesium also helps the body maintain levels of GABA (a.k.a., gamma-aminobutyric acid), a neurotransmitter that Dr. Winter notes is responsible for “turning off” wakefulness. Magnesium can also help the body’s dopamine levels rise, which can improve your mood says Dr. Winter. And if migraines are keeping you up, well, they can help alleviate those too, according to the American Migraine Foundation.