Somatic mutations in p53, which inactivate the tumour-suppressor function of p53 and often confer oncogenic gain-of-function properties, are very common in cancer1,2. Here we studied the effects of hotspot gain-of-function mutations in Trp53 (the gene that encodes p53 in mice) in mouse models of WNT-driven intestinal cancer caused by Csnk1a1 deletion3,4 or ApcMin mutation5. Cancer in these models is known to be facilitated by loss of p533,6. We found that mutant versions of p53 had contrasting effects in different segments of the gut: in the distal gut, mutant p53 had the expected oncogenic effect; however, in the proximal gut and in tumour organoids it had a pronounced tumour-suppressive effect. In the tumour-suppressive mode, mutant p53 eliminated dysplasia and tumorigenesis in Csnk1a1-deficient and ApcMin/+ mice, and promoted normal growth and differentiation of tumour organoids derived from these mice. In these settings, mutant p53 was more effective than wild-type p53 at inhibiting tumour formation. Mechanistically, the tumour-suppressive effects of mutant p53 were driven by disruption of the WNT pathway, through preventing the binding of TCF4 to chromatin. Notably, this tumour-suppressive effect was completely abolished by the gut microbiome. Moreover, a single metabolite derived from the gut microbiota-gallic acid-could reproduce the entire effect of the microbiome. Supplementing gut-sterilized p53-mutant mice and p53-mutant organoids with gallic acid reinstated the TCF4-chromatin interaction and the hyperactivation of WNT, thus conferring a malignant phenotype to the organoids and throughout the gut. Our study demonstrates the substantial plasticity of a cancer mutation and highlights the role of the microenvironment in determining its functional outcome.