The extent to which tissue-specific viral infections generate memory T cells specifically adapted to and maintained within the target infection site is unknown. Here, we show that respiratory virus-specific memory T cells in mice and humans are generated and maintained in compartmentalized niches in lungs, distinct from populations in lymphoid tissue or circulation. Using a polyclonal mouse model of influenza infection combined with an in vivo antibody labeling approach and confocal imaging, we identify a spatially distinct niche in the lung where influenza-specific T-cell responses are expanded and maintained long term as tissue-resident memory (T(RM)) CD4 and CD8 T cells. Lung T(RM) are further distinguished from circulating memory subsets in lung and spleen based on CD69 expression and persistence independent of lymphoid stores. In humans, influenza-specific T cells are enriched within the lung T(RM) subset, whereas memory CD8 T cells specific for the systemic virus cytomegalovirus are distributed in both lung and spleen, suggesting that the site of infection affects T(RM) generation. Our findings reveal a precise spatial organization to virus-specific T-cell memory, determined by the site of the initial infection, with important implications for the development of targeted strategies to boost immunity at appropriate tissue sites.