ObjectsThis study aimed to investigate the impact of lipoprotein(a) [Lp(a)] levels on the prognosis of Chinese patients with ST-segment elevation myocardial infarction (STEMI), and to explore if the impact may differ in the diabetes mellitus (DM) and nonDM groups.MethodsBetween March 2017 and January 2020, 1543 patients with STEMI who underwent emergency percutaneous coronary intervention (PCI) were prospectively recruited. The primary outcome was a composite of all-cause death, MI recurrence (reMI), and stroke, known as major adverse cardiovascular events (MACE). Analyses involving the Kaplan–Meier curve, Cox regression, and restricted cubic spline (RCS) were conducted.ResultsDuring the 1446-day follow-up period, 275 patients (17.8%) experienced MACEs, including 141 with DM (20.8%) and 134 (15.5%) without DM. As for the DM group, patients with Lp(a) ≥ 50 mg/dL showed an apparently higher MACE risk compared to those with Lp(a) < 10 mg/dL (adjusted hazard ratio [HR]: 1.85, 95% confidence interval [CI]:1.10–3.11,P= 0.021). The RCS curve indicates that the HR for MACE appeared to increase linearly with Lp(a) levels exceeding 16.9 mg/dL. However, no similar associations were obtained in the nonDM group, with an adjusted HR value of 0.57 (Lp(a) ≥ 50 mg/dL vs. < 10 mg/dL: 95% CI 0.32–1.05,P= 0.071). Besides, compared to patients without DM and Lp(a) ≥ 30 mg/dL, the MACE risk of patients in the other three groups (nonDM with Lp(a) < 30 mg/dL, DM with Lp(a) < 30 mg/dL, and DM with Lp(a) ≥ 30 mg/dL) increased to 1.67-fold (95% CI 1.11–2.50,P= 0.013), 1.53-fold (95% CI 1.02–2.31,P= 0.041), and 2.08-fold (95% CI 1.33–3.26,P= 0.001), respectively.ConclusionsIn this contemporary STEMI population, high Lp(a) levels were linked to an increased MACE risk, and very high Lp(a) levels (≥ 50 mg/dL) significantly indicated poor outcomes in patients with DM, while not for those without DM.Trial registration: clinicaltrials.gov NCT: 03593928Supplementary InformationThe online version contains supplementary material available at 10.1186/s12933-023-01881-w.