Background: Whether diabetes mellitus (DM) increases gastric cancer (GC) risk remains controversial due to inadequate adjustment for important risk factors, including Helicobacter pylori (HP) status, concomitant medication usage and cancer site. We aimed to investigate whether type II diabetes mellitus (DM) increased GC risk in patients after HP treatment. Research design and methods: This was a territory-wide cohort study of patients aged ≥45 years who had received clarithromycin-based triple therapy for HP between 2003 and 2012 in Hong Kong. Data were retrieved from the public electronic health database. Observation started from HP therapy to GC diagnosis, death or end of study (December 2015). Exclusion criteria included type I DM, GC diagnosed within first year of HP therapy, prior GC or gastrectomy, and retreatment for HP. The adjusted hazard ratio (aHR) of GC with type II DM was calculated by Cox model with propensity score regression adjustment for 20 covariates (age, sex, comorbidities and medications). Results: During a median follow-up of 7.1 years (IQR:4.8-9.3), 153 (0.33%) of 46,460 patients developed GC at a median age of 72.4 years. Type II DM was associated with an increased GC risk (aHR:1.73; 95% CI:1.08-2.79). Stratified analysis showed increase in risk for cardia cancer only (aHR:3.40, 95% CI:1.45-7.97) and those with suboptimal DM control (time-weighted average HbA1c ≥6.0% [42mmol/mol]; aHR:1.68, 95% CI:1.07-2.63). Conclusions: Type II DM was associated with an increased GC risk among HPeradicated patients, in particular cardia GC and those with suboptimal DM control.