Naïve CD8 T cells have the potential to differentiate into a spectrum of functional states during an immune response. How these developmental decisions are made and what mechanisms exist to suppress differentiation toward alternative fates remains unclear. We employed in vivo CRISPR-Cas9-based perturbation sequencing to assess the role of ~40 transcription factors (TFs) and epigenetic modulators in T cell fate decisions. Unexpectedly, we found that knockout of the TF Klf2 resulted in aberrant differentiation to exhausted-like CD8 T cells during acute infection. KLF2 was required to suppress the exhaustion-promoting TF TOX and to enable the TF TBET to drive effector differentiation. KLF2 was also necessary to maintain a polyfunctional tumor-specific progenitor state. Thus, KLF2 provides effector CD8 T cell lineage fidelity and suppresses the exhaustion program.