Immune cells must adapt to different environments during the course of an immune response. We studied the adaptation of CD8 + T cells to the intestinal microenvironment and how this process shapes their residency in the gut. CD8 + T cells progressively remodel their transcriptome and surface phenotype as they acquire gut residency, and downregulate expression of mitochondrial genes. Human and mouse gut-resident CD8 + T cells have reduced mitochondrial mass, but maintain a viable energy balance to sustain their function. We found that the intestinal microenvironment is rich in prostaglandin E 2 (PGE 2 ), which drives mitochondrial depolarization in CD8 + T cells. Consequently, these cells engage autophagy to clear depolarized mitochondria, and enhance glutathione synthesis to scavenge reactive oxygen species (ROS) that result from mitochondrial depolarization. Impairing PGE 2 sensing promotes CD8 + T cell accumulation in the gut, while tampering with autophagy and glutathione negatively impacts the T cell population. Thus, a PGE 2 -autophagy-glutathione axis defines the metabolic adaptation of CD8 + T cells to the intestinal microenvironment, to ultimately influence the T cell pool.