Cyclophosphamide is one of several clinically important cancer drugs whose therapeutic efficacy is due in part to their ability to stimulate antitumor immune responses. Studying mouse models, we demonstrate that cyclophosphamide alters the composition of microbiota in the small intestine and induces the translocation of selected species of Gram-positive bacteria into secondary lymphoid organs. There, these bacteria stimulate the generation of a specific subset of “pathogenic” T helper 17 (pTH17) cells and memory TH1 immune responses. Tumor-bearing mice that were germ-free or that had been treated with antibiotics to kill Gram-positive bacteria showed a reduction in pTH17 responses, and their tumors were resistant to cyclophosphamide. Adoptive transfer of pTH17 cells partially restored the antitumor efficacy of cyclophosphamide. These results suggest that the gut microbiota help shape the anticancer immune response.