Pancreatitis and diabetes are established risk factors for pancreatic cancer. However, to date, studies have investigated only the risk associated with either of them alone. The aim of this study was to investigate the effect of pancreatitis and diabetes combined, as well as their temporal relationship, on the risk of pancreatic cancer.Nationwide cancer registry was linked to hospital discharge and mortality data from 1998 to 2015 in New Zealand. Incidence of primary pancreatic cancer in the four study groups (type 2 diabetes [T2D] alone, pancreatitis alone, T2D followed by pancreatitis, and postpancreatitis diabetes mellitus [PPDM]) was identified. Multivariable Cox regression analyses were conducted, with T2D as the reference group. A head-to-head comparison between the T2D followed by pancreatitis and PPDM groups was also performed.Among 139,843 individuals (735,541 person-years), 913 (0.7%) were diagnosed with pancreatic cancer. The proportion of pancreatic cancer was 3.1%, 2.3%, 2.0%, and 0.6% in individuals with PPDM, T2D followed by pancreatitis, pancreatitis alone, and T2D alone, respectively. PPDM (hazard ratio [HR] 6.94; 95% CI 4.09-11.77) and T2D followed by pancreatitis (HR 5.35; 95% CI 3.52-8.14) were associated with significantly higher risks of pancreatic cancer compared with T2D alone. In the head-to-head comparison, PPDM was associated with a higher risk of pancreatic cancer compared with T2D followed by pancreatitis (HR 2.35; 95% CI 1.12-4.93).Pancreatitis significantly increases the risk of pancreatic cancer in individuals with diabetes. In particular, PPDM poses the highest risk for pancreatic cancer.