Mucous-producing cells at the neck of the gastric pits create a layer of protective mucous covering the stomach lining. This mucous layer includes bicarbonate ions which act as a chemical barrier against the protons in gastric juice. See here for some evidence.
The stomach lining stays protected because the mucous layer is continuously replenished.