Yes, you can generally take magnesium and ibuprofen together for short-term use. There is no dangerous drug interaction between the two. However, one specific form of magnesium, magnesium hydroxide (the kind found in antacids like Milk of Magnesia), can increase stomach irritation when paired with ibuprofen, so the combination deserves a closer look before you make it a habit.
Why the Combination Is Usually Safe
Magnesium supplements and ibuprofen work through completely different pathways in your body. Magnesium is a mineral involved in muscle relaxation, nerve signaling, and hundreds of enzymatic processes. Ibuprofen is a nonsteroidal anti-inflammatory drug (NSAID) that reduces pain and inflammation by blocking certain chemical signals. Taking them on the same day, or even at the same time, does not create a dangerous interaction for most people.
That said, “no dangerous interaction” doesn’t mean the pairing is completely neutral. The form of magnesium you take matters, and so does how long and how frequently you use both together.
The Magnesium Hydroxide Exception
Magnesium hydroxide is the form found in many antacids and some laxatives. When researchers gave healthy volunteers ibuprofen tablets that contained magnesium hydroxide as a buffering agent, the results were surprisingly counterproductive. In a controlled study, the number of people who developed small stomach erosions roughly doubled compared to those who took standard ibuprofen. In the lower part of the stomach (the antrum), 13 out of the volunteers developed erosions with the magnesium hydroxide formulation versus just 5 with conventional ibuprofen.
The reason appears to be that magnesium hydroxide increases ibuprofen’s solubility and speeds up how quickly the drug dissolves in the stomach. Lab studies confirm that magnesium ions form a more soluble compound with ibuprofen, which means more of the drug hits the stomach lining faster. That concentrated local exposure is what drives the irritation. The researchers concluded that prolonged use of magnesium hydroxide alongside high doses of ibuprofen should be avoided because of this elevated risk of gastrointestinal damage.
How Different Magnesium Forms Compare
The stomach irritation findings are specific to magnesium hydroxide. Most people taking magnesium supplements are using a different form entirely, such as magnesium glycinate, magnesium citrate, or magnesium oxide. These forms don’t dissolve ibuprofen the same way magnesium hydroxide does.
Magnesium glycinate is bound to the amino acid glycine and is absorbed in the intestines rather than reacting with stomach acid the way an antacid would. Magnesium citrate is bound to citric acid and also behaves differently in the stomach environment. Neither of these has been shown to cause the same increase in ibuprofen absorption or stomach erosion risk. If you take one of these common supplement forms alongside occasional ibuprofen, the concern about stomach irritation is much lower than it would be with an antacid-style magnesium product.
Potential Benefits for Migraine
Interestingly, using magnesium and ibuprofen together may actually improve pain relief in certain situations. A study of 160 children ages 5 to 16 with frequent migraines tested ibuprofen and acetaminophen both with and without daily magnesium supplementation over 18 months. Children who received magnesium as a preventive treatment experienced significantly greater reductions in pain intensity when they took ibuprofen for an acute attack, compared to those using ibuprofen alone. The magnesium group also had significantly fewer migraine episodes per month.
The researchers concluded that magnesium increased the effectiveness of both ibuprofen and acetaminophen. This makes biological sense: magnesium plays a role in regulating the neurotransmitters and blood vessel changes involved in migraines, so addressing the underlying mineral status can make pain relievers work better when an attack hits.
Practical Tips for Taking Both
If you’re taking a standard magnesium supplement (glycinate, citrate, or oxide) and occasional over-the-counter ibuprofen, you don’t need to worry about spacing them hours apart. The lack of a clinically significant interaction between these forms means timing is flexible.
If you use magnesium hydroxide specifically, whether as an antacid or a laxative, separating it from ibuprofen by about two hours is a reasonable precaution. This gives the antacid time to move through the stomach before the ibuprofen arrives, reducing the chance that the two will interact directly on the stomach lining. This is especially important if you’re taking ibuprofen regularly rather than as a one-off dose.
A few additional points worth keeping in mind:
- Stomach protection: Taking ibuprofen with food reduces stomach irritation regardless of what supplements you’re using. This simple step matters more than any supplement timing strategy.
- Kidney considerations: Both ibuprofen and excess magnesium are processed through the kidneys. If you have reduced kidney function, your body may not clear magnesium efficiently, and ibuprofen can further reduce kidney blood flow. People with kidney disease should be cautious with this combination.
- Duration matters: A few days of overlap is very different from weeks or months. The stomach erosion risks in the research were framed around prolonged, high-dose use. Occasional use of both carries far less concern.
Which Magnesium Form to Choose
If you’re supplementing magnesium for muscle cramps, sleep, or general health and you also use ibuprofen periodically, magnesium glycinate or magnesium citrate are your best options. Both are well absorbed, less likely to cause digestive side effects on their own, and don’t carry the stomach-irritation risk that magnesium hydroxide does when paired with NSAIDs.
Magnesium oxide is cheaper and widely available, but it’s poorly absorbed and more likely to cause loose stools. It’s not the worst choice if you’re also taking ibuprofen, since it doesn’t behave like magnesium hydroxide in the stomach, but you’ll get less actual magnesium into your bloodstream per dose. For people specifically trying to prevent migraines, magnesium citrate or glycinate at doses of 400 to 500 mg per day is the range most commonly used in clinical practice.

