Gut microbiota modulate cancer control but how the different bacteria impact tumor-specific CD8+ T cell immunity remains unclear. Here, we identified that spontaneous control of cutaneous melanoma in mice correlated with microbiome-encoded metabolic pathways required for short-chain fatty acid (SCFA) synthesis. Diet-induced enforcement of microbial SCFA production reduced tumor progression and enriched tumor-specific CD8+ T cells in the tumor draining lymph node (tdLN) that lacked features of exhausted T cells. The SCFA butyrate promoted a FOXO1-dependent stemness program in these CD8+ T cells, enhanced the differentiation of CD127+CD8+ T cells and induced immune checkpoint blockade (ICB) responsiveness. Consistent with these experimental studies, metabolic modelling predicted enhanced microbial production of the SCFA butyrate in ICB-responsive melanoma patients and butyrate induced transcriptional features of ICB-responsiveness in CD8+ T cells. Collectively, these data identify the effects of microbial metabolic pathways on tumor-specific CD8+ T cell differentiation as critical components of how the gut microbiome regulates cancer immunity.