BackgroundThere is conflicting evidence regarding whether heart failure (HF) increases the risk of developing cancer.ObjectiveThis study aimed to assess the association between HF and incident cancer, considering gender differences and HF phenotypes.MethodsThis retrospective study was conducted on data of adult individuals, free of cancer at baseline, from the First Affiliated Hospital of Wenzhou Medical University between January 2009 and February 2023. The patients with HF were categorized as HF with preserved ejection fraction (HFpEF) and HF with reduced ejection fraction (HFrEF). The primary outcome was incident cancer, including obesity‐related, tobacco‐related, lung, colorectal and breast cancers.ResultsOf 33 033 individuals enrolled, 16 722 were diagnosed with HF, including 10 086 (60.3%) with HFpEF and 6636 (39.7%) with HFrEF. During a median follow‐up period of 4.6 years (inter‐quartile range: 2.6–7.3), incident cancer was diagnosed in 10.5% (1707 patients) of the non‐HF group and 15.1% (2533 individuals) of the HF group. After adjusting for potential confounding factors, patients with HF had a 58% increased risk of cancer than those without HF [adjusted hazard ratio (HR) 1.58, 95% confidence interval (CI) 1.48–1.69, P < 0.001]. This risk was consistent across genders (female: adjusted HR 1.95, 95% CI 1.74–2.18, P < 0.001; male: adjusted HR 1.41, 95% CI 1.30–1.54, P < 0.001) and HF phenotypes (HFpEF: adjusted HR 1.69, 95% CI 1.57–1.81, P < 0.001; HFrEF: adjusted HR 1.32, 95% CI 1.20–1.46, P < 0.001).ConclusionsBoth HFpEF and HFrEF are associated with an increased risk of incident cancer. This correlation maintains its validity across genders.