Aging is often associated with a decline in hippocampus-dependent spatial memory. Here, we show that functional cell-mediated immunity is required for the maintenance of hippocampus-dependent spatial memory. Sudden imposition of immune compromise in young mice caused spatial memory impairment, whereas immune reconstitution reversed memory deficit in immune-deficient mice. Analysis of hippocampal gene expression suggested that immune-dependent spatial memory performance was associated with the expression of insulin-like growth factor (Igf1) and of genes encoding proteins related to presynaptic activity (Syt10, Cplx2). We further showed that memory loss in aged mice could be attributed to age-related attenuation of the immune response and could be reversed by immune system activation. Homeostatic-driven proliferation of lymphocytes, which expands the existing T cell repertoire, restored spatial memory deficits in aged mice. Thus, our results identify a novel function of the immune system in the maintenance of spatial memory and suggest an original approach for arresting or reversing age-associated memory loss.