Pathogens often infect hosts through collective actions: they secrete growth-promoting compounds or virulence factors, or evoke host reactions that fuel the colonization of the host. Such behaviours are vulnerable to the rise of mutants that benefit from the collective action without contributing to it; how these behaviours can be evolutionarily stable is not well understood. We address this question using the intestinal pathogen Salmonella enterica serovar Typhimurium (hereafter termed S. typhimurium), which manipulates its host to induce inflammation, and thereby outcompetes the commensal microbiota. Notably, the virulence factors needed for host manipulation are expressed in a bistable fashion, leading to a slow-growing subpopulation that expresses virulence genes, and a fast-growing subpopulation that is phenotypically avirulent. Here we show that the expression of the genetically identical but phenotypically avirulent subpopulation is essential for the evolutionary stability of virulence in this pathogen. Using a combination of mathematical modelling, experimental evolution and competition experiments we found that within-host evolution leads to the emergence of mutants that are genetically avirulent and fast-growing. These mutants are defectors that exploit inflammation without contributing to it. In infection experiments initiated with wild-type S. typhimurium, defectors increase only slowly in frequency. In a genetically modified S. typhimurium strain in which the phenotypically avirulent subpopulation is reduced in size, defectors rise more rapidly, inflammation ceases prematurely, and S. typhimurium is quickly cleared from the gut. Our results establish that host manipulation by S. typhimurium is a cooperative trait that is vulnerable to the rise of avirulent defectors; the expression of a phenotypically avirulent subpopulation that grows as fast as defectors slows down this process, and thereby promotes the evolutionary stability of virulence. This points to a key role of bistable virulence gene expression in stabilizing cooperative virulence and may lead the way to new approaches for controlling pathogens.