Background: Cholecystitis before cholecystectomy may increase risk of cancers in the hepato-pancreato-biliary area. Methods: A population-based cohort study of all patients undergoing cholecystectomy in Denmark during 1996–2015, using nationwide healthcare registries. We retrieved information on cholecystitis within two years before the date of surgery and information on pancreatic cancer, hepatocellular carcinoma (HCC), and biliary tract cancer. We examined cancer risk using a Cox model to calculate the hazard ratios (HRs). We also computed cumulative incidence functions with 95% CIs, comparing patients with and without cholecystitis before cholecystectomy. Results: We included 132,794 patients, of which 73.0% were women. In the first five years of follow-up, we observed an increased risk of biliary tract cancer, but not pancreatic cancer or HCC, in patients with prior cholecystitis. After more than five years of follow-up, patients with prior cholecystitis had an increased risk of pancreatic cancer (adjusted HR: 1.26; 95% CI: 0.98–1.63) and possibly biliary tract cancer (adjusted HR: 1.33; 95% CI: 0.64–2.77). Long-term risk of HCC was decreased in patients with prior cholecystitis. For all cancers, the 20-year absolute risks were less than 1%. Conclusion: In patients undergoing cholecystectomy, prior cholecystitis was associated with increased risk of pancreatic and possibly biliary tract cancer.