Migraines are notoriously difficult to control. But now there may be one surprising treatment that can stop the brutal headache before it even starts: marijuana.

At least, that’s what research presented at the Congress of the European Academy of Neurology in Amsterdam suggests.

In the first part of the study, researchers recruited 48 chronic migraine sufferers to determine an effective dosage of a combination of tetrahydrocannabinol (THC)—the psychoactive component of marijuana—and bedrolite, a cannabidiol found in pot, in reducing headache pain.

After testing the combination on volunteers, they found no benefit in pain reduction until it reached 100 milligrams (mg).

They discovered the therapeutic dose to be 200 mg, which led to a 55 percent decrease in pain.

In the second part of the study, the researchers tested how effective the 200 mg THC/cannabidoil combo was at preventing headache in 79 migraine and 48 cluster headache sufferers, in comparison to more tried-and-true methods.

After three months of treatment, the oral cannabinoid combo triggered a 40.4 percent reduction in headache attacks in the migraine sufferers—just slightly better than the 40.1 percent drop seen in those given the antidepressant amitriptyline to thwart the attacks.

Side effects of the treatment included drowsiness and trouble paying attention, the researchers found.

Because this research has only been presented at a conference, it hasn’t yet undergone a peer review, so it’s still considered preliminary.

And it’s not clear if consuming marijuana in a typical fashion—say, smoking a joint instead of consuming the specific oral combination—would have the same effect.

Still, it’s not the first to link marijuana to a migraine benefit. Last year, a study published in Pharmacotherapy found that medical marijuana use decreased headache frequency from just over 10 a month to less than five.

Experts aren’t sure exactly how it helps, but they believe cannabinoids may prevent the release of a neurotransmitter called serotonin.