China has the largest burden of heart failure worldwide. However, large-scale studies on heart failure mortality are scarce. We aimed to investigate mortality and identify risk factors for mortality among patients with heart failure in China. This prospective cohort study used data from the China Cardiovascular Association (CCA) Database-Heart Failure Centre Registry, which were linked to the National Mortality Registration Information Management System by the Chinese Centre for Disease Control and Prevention. We included patients enrolled from Jan 1, 2017, to Dec 31, 2021, across 572 CCA Database-Heart Failure Centre certified hospitals in 31 provinces of mainland China. Eligible patients were aged 18 years or older (younger than 100 years) with a principal discharge diagnosis of heart failure based on Chinese heart failure guidelines. All-cause mortality at 30 days, 1 year, and 3 years for patients with heart failure were calculated and the causes of death were recorded. Multivariable analysis was used to analyse factors associated with all-cause mortality and cardiovascular mortality. This study was registered with the Chinese Clinical Trial Registry, ChiCTR2200066305. Of the 327 477 patients in the registry, 230 637 eligible adults with heart failure were included in our analyses. Participant mean age was 69·3 years (SD 13·2), 94 693 (41·1%) participants were female, and 135 944 (58·9%) were male. The median follow-up time was 531 days (IQR 251-883). Post-discharge all-cause mortality of patients with heart failure at 30 days was 2·4% (95% CI 2·3-2·5), at 1 year was 13·7% (13·5-13·9), and at 3 years was 28·2% (27·7-28·6). Cardiovascular death accounted for 32 906 (71·5%) of 46 006 all-cause deaths. Patients with heart failure with reduced ejection fraction had the highest all-cause mortality. A lower guideline adherence score was independently associated with the increase of all-cause and cardiovascular mortality. In China, mortality for patients with heart failure is still high, especially in patients with reduced ejection fraction. Our findings suggest that guideline-directed medical therapy needs to be improved. National High Level Hospital Clinical Research Funding, the Capital's Funds for Health Improvement and Research, and the Chinese Academy of Medical Sciences Innovation Fund for Medical Sciences. For the Chinese translation of the abstract see Supplementary Materials section.