Age-related thymic degeneration is associated with loss of naïve T cells, restriction of peripheral T-cell diversity, and reduced healthspan due to lower immune competence. The mechanistic basis of age-related thymic demise is unclear, but prior evidence suggests that caloric restriction (CR) can slow thymic aging by maintaining thymic epithelial cell integrity and reducing the generation of intrathymic lipid. Here we show that the prolongevity ketogenic hormone fibroblast growth factor 21 (FGF21), a member of the endocrine FGF subfamily, is expressed in thymic stromal cells along with FGF receptors and its obligate coreceptor, βKlotho. We found that FGF21 expression in thymus declines with age and is induced by CR. Genetic gain of FGF21 function in mice protects against agerelated thymic involution with an increase in earliest thymocyte progenitors and cortical thymic epithelial cells. Importantly, FGF21 overexpression reduced intrathymic lipid, increased perithymic brown adipose tissue, and elevated thymic T-cell export and naïve T-cell frequencies in old mice. Conversely, loss of FGF21 function in middle-aged mice accelerated thymic aging, increased lethality, and delayed T-cell reconstitution postirradiation and hematopoietic stem cell transplantation (HSCT). Collectively, FGF21 integrates metabolic and immune systems to prevent thymic injury and may aid in the reestablishment of a diverse T-cell repertoire in cancer patients following HSCT.