The symptoms include headache, fatigue, dizziness, nausea, vomiting and poor appetite.
In the worst cases, altitude sickness can cause cerebral edema, an often fatal brain swelling.
Ibuprofen, an active ingredient in over-the-counter painkillers like Advil, reduced altitude sickness symptoms by 26 percent in a study of 58 men and 28 women, Lipman and his research team reported.
The study was published in the online version of the Annals of Emergency Medicine.
The study participants traveled to an area of the White Mountains northeast of Bishop, California, where they spent the night at 4,100 feet.
At 8 am, they were given either 600 milligrams of ibuprofen or a placebo before heading up a mountain to a staging area at 11,700 feet. There, they were given a second dose at 2 pm.
They then hiked to 12,570 feet, where they received a third dose at 8 pm before spending the night on the mountain.
Of the 44 participants who received ibuprofen, 19, or 43 percent, suffered symptoms of altitude sickness, whereas 29 of the 42 participants who received placebos had symptoms, according to the study.
In other words, ibuprofen reduced the incidence of the illness by 26 percent, the report said.
Among study participants who suffered altitude sickness, symptoms were less severe in the persons who took ibuprofen, the researchers reported.
At high altitudes, decreased atmospheric pressure reduces oxygen molecules in the air, making it harder for people to breathe.
Some researchers believe altitude sickness occurs because a lack of oxygen to the brain causes it to swell with fluids. Ibuprofen appears to reduce the swelling, according to the Stanford researchers.
Other altitude sickness drugs are available, such as acetazolamide and dexamethasone, but they can have more undesirable side effects than ibuprofen, according to the researchers.
Ibuprofen's milder side effects can include the possibility of gastrointestinal and kidney problems in people who are dehydrated, the researchers said.