We assessed gastric cancer risk in type 2 diabetes mellitus patients. Gastric cancer patients with diabetes between 2001–2012 were identified. Four groups were analysed: combination therapy with metformin users; insulin and other medication users; metformin and insulin users; and sulfonylurea users. Standardised incidence ratios (SIRs) for gastric cancers as a ratio of the observed number of cancer cases in people with diabetes to the expected number of cancer cases in the underlying general population were calculated. A total of 99,992 patients with diabetes were analysed and 337 gastric cancer cases in patients with diabetes were observed when compared to the expected number of 400.54 gastric cancer cases, according to the cancer rates of the general population (SIR 0.84, 95% confidence interval (CI): 0.76–0.94). Lower risk of gastric cancer was found both in male and female patients with diabetes, however, risk among females was insignificantly lower. Higher gastric cancer risk was found in the group of diabetic patients treated with sulfonylureas (SIR 1.31, 95% CI: 1.04–1.65) and significantly lower risk than expected from the general population was found in the group of metformin users (SIR 0.75, 95% CI: 0.66–0.86). Type 2 diabetes mellitus was not associated with increased risk of gastric cancer. Metformin might decrease the risk of gastric cancer in patients with diabetes, while sulfonylureas may increase gastric cancer risk.