BackgroundPancreatic endocrine insufficiency is more likely to occur after acute pancreatitis (AP), but the risk factors affecting pancreatic endocrine function remain controversial. Therefore, exploring the incidence and risk factors of fasting hyperglycaemia following first-attack AP is important.MethodsData were collected from 311 individuals with first-attack AP without previous diabetes mellitus (DM) or impaired fasting glucose (IFG) history treated in the Renmin Hospital of Wuhan University. Relevant statistical tests were performed. A two-sided p-value < 0.05 was considered statistically significant.ResultsThe incidence of fasting hyperglycaemia in individuals with first-attack AP was 45.3%. Univariate analysis showed that age (χ2= 6.27,P= 0.012), aetiology (χ2= 11.184,P= 0.004), serum total cholesterol (TC) (χ2= 14.622,P< 0.001), and serum triglyceride (TG) (χ2= 15.006,P< 0.001) were significantly different between the hyperglycaemia and non-hyperglycaemia groups (P< 0.05). The serum calcium concentration (Z=-2.480,P= 0.013) was significantly different between the two groups (P< 0.05). Multiple logistic regression analysis showed that age- ≥60 years (P< 0.001, OR = 2.631, 95%Cl = 1.529–4.527) and TG ≥ 5.65 mmol/L (P< 0.001, OR = 3.964, 95%Cl = 1.990–7.895) were independent risk factors for fasting hyperglycaemia in individuals with first-attack AP (P< 0.05).ConclusionsOld age, serum triglycerides, serum total cholesterol, hypocalcaemia, and aetiology are associated with fasting hyperglycaemia following first-attack AP. Age ≥ 60 years and TG ≥ 5.65 mmol/L are independent risk factors for fasting hyperglycaemia following first-attack AP.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12876-023-02775-7.