Aims Recent reports have suggested that patients with heart failure (HF) have an altered gut microbiota composition; however, associations with diet remain largely uninvestigated. We aimed to explore differences in the gut microbiota between patients with HF with reduced ejection fraction and healthy controls, focusing on associations with diet and disease severity. Methods and results The microbiota composition of two cross-sectional cohorts (discovery, n = 40 and validation, n = 44) of patients with systolic HF and healthy controls (n = 266) was characterized by sequencing of the bacterial 16S rRNA gene. The overall microbial community (beta diversity) differed between patients with HF and healthy controls in both cohorts (P < 0.05). Patients with HF had shifts in the major bacterial phyla, resulting in a lower Firmicutes/Bacteroidetes (F/B) ratio than controls (P = 0.005). Patients reaching a clinical endpoint (listing for heart transplant or death) had lower bacterial richness and lower F/B ratio than controls (P < 0.01). Circulating levels of trimethylamine-N-oxide were associated with meat intake (P = 0.016), but not with gut microbiota alterations in HF. Low bacterial richness and low abundance of several genera in the Firmicutes phylum were associated with low fibre intake. Conclusions The gut microbiota in HF was characterized by decreased F/B ratio and reduced bacterial diversity associated with clinical outcome. The gut microbiota alterations in HF were partly related to low fibre intake, emphasizing the importance of diet as a covariate in future studies. Our data could provide a rationale for targeting the gut microbiota in HF with high-fibre diet.