Anorexia nervosa (AN) is an eating disorder with a high mortality. About 95% of cases are women and it has a population prevalence of about 1%, but evidence-based treatment is lacking. The pathogenesis of AN probably involves genetics and various environmental factors, and an altered gut microbiota has been observed in individuals with AN using amplicon sequencing and relatively small cohorts. Here we investigated whether a disrupted gut microbiota contributes to AN pathogenesis. Shotgun metagenomics and metabolomics were performed on faecal and serum samples, respectively, from a cohort of 77 females with AN and 70 healthy females. Multiple bacterial taxa (for example, Clostridium species) were altered in AN and correlated with estimates of eating behaviour and mental health. The gut virome was also altered in AN including a reduction in viral–bacterial interactions. Bacterial functional modules associated with the degradation of neurotransmitters were enriched in AN and various structural variants in bacteria were linked to metabolic features of AN. Serum metabolomics revealed an increase in metabolites associated with reduced food intake (for example, indole-3-propionic acid). Causal inference analyses implied that serum bacterial metabolites are potentially mediating the impact of an altered gut microbiota on AN behaviour. Further, we performed faecal microbiota transplantation from AN cases to germ-free mice under energy-restricted feeding to mirror AN eating behaviour. We found that the reduced weight gain and induced hypothalamic and adipose tissue gene expression were related to aberrant energy metabolism and eating behaviour. Our ‘omics’ and mechanistic studies imply that a disruptive gut microbiome may contribute to AN pathogenesis.