Breastfeeding is an obligatory requirement of mammalian survival. This fundamental process is associated with the adaptation of maternal physiology, including the transformation of the mammary gland into a milk-secreting organ. How maternal immunity contributes to mammary gland remodeling and function remains largely unknown. Here, we show that maternal adaptive immunity plays a critical role in shaping lactogenesis. Specifically, physiological adaptation during pregnancy is associated with thymic involution and a paradoxical enrichment in intraepithelial lymphocyte (IEL) precursors that no longer migrate to the gut but instead preferentially accumulate within the mammary gland. IEL precursors differentiate into T-bet-expressing unconventional CD8αα lymphocytes in an IL-15-dependent manner. Mammary IELs control milk production by favoring the differentiation and maturation of contractile and milk-secreting cells, thereby promoting offspring fitness. Altogether, this work uncovers a contribution of the maternal adaptive immune system in organismal remodeling during pregnancy that is associated with mammary gland development and function.