Helicobacter pylori infection is associated with the risk of gastrointestinal (GI) cancers; however, its impact on immunotherapy for GI cancers remains uncertain. In this study, we included 10,122 patients who underwent 13C-urea breath tests. Among 636 patients with Epstein-Barr virus–negative microsatellite-stable gastric cancer (GC) who were treated with anti-PD-1/PD-L1 therapy, H. pylori–positive patients exhibited significantly longer immune-related progression-free survival (irPFS) compared with H. pylori–negative patients (6.97 months versus 5.03 months, p