Ranitidine works by blocking the action of histamine in the stomach. This decreases the amount of acid the stomach produces, which helps to relieve symptoms of heartburn, acid indigestion, and sour stomach. Ranitidine is used for treating or preventing heartburn, acid indigestion, and sour stomach caused by certain foods and drinks.