The processing of pain in the central nervous system is now known to have an important immune component, including T cells of the adaptive immune system. T cells have been shown to release endogenous opioids, and although it is well known that opioids have effects on T-cell populations, very little attention has been given to the converse: how T cells may affect opioid regulation. We find here that, in addition to displaying significantly increased baseline pain sensitivity across various pain modalities, T-cell-deficient mice (CD-1 nude, Rag1 null mutant, and Cd4 null mutant) exhibit pronounced deficiencies in morphine inhibition of thermal or inflammatory pain. Nude mice are also deficient in endogenous opioid-mediated analgesia, exhibiting no stress-induced analgesia from restraint. The relevant T-cell subpopulation seems to be CD4 T cells because adoptive transfer of them but not CD8 cells into nude mice rescues both the pain and morphine analgesia phenotypes. As previously reported, we also observe a sex difference in CD-1 mice, with females requiring 2- to 3-fold more morphine than males to produce equal analgesia. Nude mice display no sex differences in morphine analgesia, and the sex difference is restored in nude mice of either sex receiving CD4 T cells from CD-1 donor male or female mice. These results suggest that CD4 T cells play an as yet unappreciated role in opioid analgesia and may be a driver of sex differences therein.