To analyze the predictive value of hyperglycemia on the extrapancreatic infection (EPI) and infected pancreatic necrosis (IPN) of severe patients with acute pancreatitis (AP). We enrolled 234 patients with acute pancreatitis admitted to the intensive care unit (ICU) of the Second Affiliated Hospital of Nanchang University from July 2017 to July 2022 for a retrospective cohort study. We collected maximum blood glucose values three times after admission to the ICU within 120 h (Glu1: 0–24 h, Glu2: 24–48 h, Glu3: 48–120 h), the levels of leucocyte, blood urea nitrogen (BUN), C-reactive protein (CRP), procalcitonin (PCT), and albumin within 24 h after admission to the ICU, and the BISAP and SIRS scores of all patients within 24 h. EPI was taken as the primary outcome indicator and IPN as the secondary outcome indicator. The accuracy of blood glucose values in predicting acute pancreatitis infection was measured by the area under the curve (AUC). A total of 56 patients appeared EPI. Univariate analysis showed that Glu3 was associated with IPN in critically ill patients with AP. Multivariate logistic regression analysis showed that Glu2, Glu3, and SIRS > 48 h were associated with EPI in critically ill patients with AP. The AUCs of Glu2 and Glu3 to predict EPI were 0.805(95%CI: 0.717–0.892) and 0.782(95%CI: 0.685–0.878), respectively, and the cutoff values were 12.60 mmol/L and 14.75 mmol/L, respectively. The AUC of Glu2 combined with Glu3 to predict EPI was 0.812(0.725–0.899). The maximum blood glucose on Day2-5 after admission to the ICU can predict infection in critically ill patients with AP. There are differences in etiology while glucose predicting infection. Patients with hypertriglyceridemia AP need to intervene blood glucose levels more actively and earlier, and control it more strictly.