A range of microbiota species correlate with improved cancer outcomes in patients and confer protection in pre-clinical mouse models. Here we examined how microbiota regulate CD8+ T cell immunity against melanoma. Spontaneous control of cutaneous melanoma in mice correlated with metabolic pathways required for microbial synthesis of short-chain fatty acids (SCFA) shared between several microbiota species. Diet-induced enforcement of SCFA production by the gut microbiota reduced melanoma progression and enriched tumor-specific stem-like CD127+CD8+ T cells in the tumor draining lymph node (tdLN). The SCFA butyrate directly promoted the differentiation of tumor-specific CD127+CD8+ T cells in the tdLN and induced a FOXO1-driven stemness program. Metabolic flux modelling predicted enhanced microbial production of butyrate in patients with complete therapeutic responses to immune checkpoint blockade (ICB), and butyrate induced transcriptional features of ICB-responsiveness in CD8+ T cells. Our findings suggest a critical role for metabolite production shared across several microbiota species in the preservation of stem-like tumor-specific CD8+ T cells.