Intestinal microbiota have been proposed to induce commensal-specific memory T cells that cross-react with tumor-associated antigens. We identified major histocompatibility complex (MHC) class I–binding epitopes in the tail length tape measure protein (TMP) of a prophage found in the genome of the bacteriophage Enterococcus hirae. Mice bearing E. hirae harboring this prophage mounted a TMP-specific H-2Kb–restricted CD8+ T lymphocyte response upon immunotherapy with cyclophosphamide or anti–PD-1 antibodies. Administration of bacterial strains engineered to express the TMP epitope improved immunotherapy in mice. In renal and lung cancer patients, the presence of the enterococcal prophage in stools and expression of a TMP–cross-reactive antigen by tumors correlated with long-term benefit of PD-1 blockade therapy. In melanoma patients, T cell clones recognizing naturally processed cancer antigens that are cross-reactive with microbial peptides were detected.