The long-lived protective immunity elicited by vaccines and many naturally occurring infections, which is mediated by expanded populations of previously activated B and T cells selected for their expression of specific receptors for the antigens of a given pathogen.