It is used to treat gastroesophageal reflux disease (GERD; acid reflux). It is used to treat or prevent GI (gastrointestinal) ulcers caused by infection. It is used to treat or prevent ulcers of the swallowing tube (esophagus). It is used to treat syndromes caused by lots of stomach acid. It is used to treat or prevent nonsteroidal anti-inflammatory drugs (NSAID)-associated gastric ulcers in patients with a history of ulcers. Examples of NSAIDs include ibuprofen and naproxen. It is used to treat heartburn. It may be given to you for other reasons. Talk with the doctor.