During an infection, T cells can differentiate into multiple types of effector and memory T cells, which help to mediate pathogen clearance and provide long-term protective immunity. These cells can vary in their phenotype, function and location, and in their long-term fate in terms of their ability to populate the memory T cell pool. Over the past decade, the signalling pathways and transcriptional programmes that regulate the formation of heterogeneous populations of effector and memory CD8(+) T cells have started to be characterized, and this Review discusses the major advances in these areas.