To analyze the influence of diabetes mellitus on the clinical outcomes of moderately severe acute pancreatitis (MSAP) and severe acute pancreatitis (SAP). This retrospective study included patients diagnosed with MSAP and SAP at Shanxi Bethune Hospital from January 1, 2017, to December 31, 2021. Clinical data were collected, including patient demographics, 24-hour laboratory indicators, and inflammation indices. Propensity score matching (PSM) was used to compare outcomes before and after matching. Patients were randomized into training and validation sets (7:3) to develop and validate a clinical prediction model for infected pancreatic necrosis (IPN). Among 421 patients, 79had diabetes at admission. Before PSM, diabetic patients had higher incidences of peripancreatic fluid (71% vs 47%, p<0.001) and IPN (48% vs 10%, p<0.001), higher surgical intervention rates (24% vs 12%, p=0.008), and significant differences in abdominocentesis (22% vs 11%, p=0.014). After PSM, 174 patients were matched, and the diabetes group still showed higher incidences of peripancreatic fluid (69% vs 47%, p=0.008), IPN (48% vs 11%, p<0.001), and surgical intervention rates (27% vs 13%, p=0.037). Diabetes, modified CT severity index (MCTSI), serum calcium, and HDL-c were identified as independent risk factors for IPN. The prediction model demonstrated good predictive value. In MSAP and SAP patients, diabetes mellitus can exert an influence on their clinical outcome and is an independent risk factor for IPN. The alignment diagram and web calculator constructed on the basis of diabetes mellitus, modified CT severity index (MCTSI), serum calcium and high-density lipoprotein cholesterol (HDL-c) have good predictive value and clinical guidance for the occurrence of IPN in MSAP and SAP.