A small randomized trial has found that acute mountain sickness — the headache, fatigue, dizziness, nausea and vomiting that can occur at altitudes above 8,000 feet — can effectively be prevented with a common and inexpensive over-the-counter medicine: ibuprofen, sold as Advil and other brands.

Usually, the illness goes away by itself, but if left untreated, it can progress to extreme debility and, in rare cases, fatal swelling of the brain. Ibuprofen may be safer and have fewer side effects than the usual medicines for altitude sickness: dexamethasone, a steroid, and acetazolamide, a diuretic.

In the study, published online in Annals of Emergency Medicine, researchers randomly assigned 86 hikers to take either 600 milligrams of ibuprofen or a placebo at four intervals as they climbed from 4,100 feet to 12,570 feet. The subjects responded to a questionnaire reporting symptoms and rating their severity.

In the placebo group, 69 percent developed severe mountain sickness, compared with 43 percent of those on ibuprofen. Among those who fell ill, symptoms were slightly milder among those taking ibuprofen, but that difference was not statistically significant.