What Causes an Ulcer in the Stomach: H. pylori & NSAIDs

Most stomach ulcers are caused by one of two things: a bacterial infection called H. pylori or regular use of common pain relievers like ibuprofen and aspirin. These two causes account for the vast majority of cases. Spicy food and emotional stress, long blamed for ulcers, don’t actually cause them.

How H. pylori Bacteria Damage the Stomach Lining

H. pylori is a spiral-shaped bacterium that can survive in the harsh acid environment of your stomach. It burrows into the protective mucus layer that shields your stomach wall from its own digestive acid. Once established, the bacteria produce substances that directly affect the cells responsible for acid production and the cells that regulate how much acid your stomach makes. This disrupts the delicate balance between acid output and the stomach’s natural defenses, eventually eating through the lining and creating an open sore.

What makes H. pylori particularly persistent is its ability to switch genes on and off depending on its environment. It attaches specifically to gastric cells through a targeted chemical process, meaning it has evolved to colonize the stomach in ways other bacteria cannot. Many people carry H. pylori for years without developing an ulcer, but in some individuals, the infection tips the balance far enough that the acid overwhelms the mucus barrier.

Roughly half the world’s population carries H. pylori, though infection rates are higher in developing countries and in older adults. Not everyone who is infected develops ulcers, but the bacterium is present in most stomach ulcer cases not linked to pain medications.

Why Common Pain Relievers Cause Ulcers

Nonsteroidal anti-inflammatory drugs, known as NSAIDs, are the second leading cause of stomach ulcers. This category includes over-the-counter medications like ibuprofen, naproxen, and aspirin. These drugs work by blocking an enzyme involved in inflammation, but that same enzyme also helps maintain the protective lining of your stomach. When it’s suppressed, your stomach becomes more vulnerable to its own acid.

The damage can happen faster than most people realize. Ulcers can develop within one week of regular NSAID use, with studies showing about an 8% incidence of ulcers after just seven days of standard dosing. With continued use, the numbers climb steeply: the cumulative incidence of ulcers has been reported as high as 25% to 30% at three months and 45% at six months. Even aspirin at relatively modest doses (650 mg taken four times daily) can produce gastric erosions within 24 hours.

Several factors increase your risk of developing an NSAID-related ulcer. Taking higher doses, using the drugs for longer periods, and combining them with blood thinners or corticosteroids all raise the likelihood significantly. Older adults and people with a history of ulcers are especially vulnerable. If you take NSAIDs regularly, your doctor may prescribe a medication to protect your stomach lining.

Smoking, Alcohol, and Other Risk Factors

Smoking and heavy alcohol use don’t cause ulcers on their own in the way H. pylori or NSAIDs do, but they make the stomach lining significantly more fragile. Nicotine causes microscopic damage to the stomach’s mucosal layer and worsens the harm done by alcohol. Both substances appear to work partly by disrupting blood flow to the stomach wall, which impairs its ability to repair itself. Together, they compound each other’s effects, creating conditions where an ulcer is more likely to form and slower to heal.

People who smoke are also more likely to have H. pylori infections persist and are slower to recover once treatment begins.

Spicy Food and Stress Don’t Cause Ulcers

For decades, doctors told patients that spicy food and psychological stress were primary causes of stomach ulcers. That theory was debunked in the 1980s after the discovery of H. pylori’s role. Research on capsaicin, the compound that makes peppers hot, has actually shown the opposite of what people assumed: capsaicin stimulates the stomach to produce protective mechanisms against ulcers. There is also no evidence that spicy food worsens ulcers that have already formed.

That said, if spicy food or any other food gives you abdominal discomfort, it makes sense to avoid it. The discomfort is real, even if it isn’t causing structural damage. Emotional stress similarly won’t create an ulcer, though it can increase acid production and make existing symptoms feel worse.

There is one important distinction here: physiological stress from a serious medical crisis is different from everyday emotional stress. Critically ill patients in intensive care can develop what are called stress ulcers, caused by reduced blood flow to the stomach lining during severe illness or injury. This is a hospital-level concern, not something triggered by a bad week at work.

Rare Causes Worth Knowing About

A small number of stomach ulcers result from a condition called Zollinger-Ellison syndrome. In this disorder, tumors called gastrinomas form in the pancreas or upper small intestine and produce large amounts of the hormone gastrin. Gastrin signals your stomach to make acid, so these tumors essentially flood the stomach with far more acid than normal. The excess acid overwhelms the protective lining and leads to severe, often multiple ulcers. Diarrhea is another common symptom. Zollinger-Ellison syndrome is rare, but doctors consider it when ulcers keep recurring despite standard treatment or when they appear in unusual locations.

How Stomach Ulcers Are Detected

If your doctor suspects an ulcer, the first step is usually testing for H. pylori. The most common noninvasive option is a urea breath test, which has a sensitivity of about 92% to 94%, meaning it correctly identifies the infection in the vast majority of cases. A stool antigen test is another option, though it’s slightly less sensitive at around 83%. Both are compared against the gold standard of endoscopic biopsy, where a small camera is passed into the stomach and tissue samples are taken directly.

An endoscopy is typically reserved for people over 60, those with alarming symptoms like unexplained weight loss or difficulty swallowing, or cases where initial treatment hasn’t worked. During the procedure, the doctor can see the ulcer directly, check its size and severity, and rule out other conditions.

How Treatment Works

Treatment depends on the cause. If H. pylori is present, you’ll take a combination of antibiotics along with an acid-reducing medication for about two weeks. The antibiotics clear the infection while the acid reducer gives the ulcer time to heal. Most ulcers heal within four to eight weeks once the underlying cause is addressed. Your doctor will typically retest for H. pylori after treatment to confirm the bacteria are gone.

For NSAID-related ulcers, the primary step is stopping or reducing the offending medication. If you need to continue taking NSAIDs for another condition, your doctor may switch you to a lower-risk alternative or add a stomach-protecting medication to your regimen. Acid-reducing drugs help the ulcer heal, but it will likely return if the same pattern of NSAID use continues without protection.

Left untreated, stomach ulcers can lead to serious complications, including bleeding into the digestive tract, perforation of the stomach wall, or scar tissue that blocks food from moving through the stomach. Symptoms like vomiting blood, black or tarry stools, sudden severe abdominal pain, or unexplained weight loss signal that an ulcer may be worsening and needs prompt attention.