T cell activation plays a central role in immune response and in the maintenance of self-tolerance. We analyzed the evolutionary history of T cell regulatory molecules. Nine genes involved in triggering T cell activation or in regulating the ensuing response evolved adaptively in mammals. Several positively selected sites overlap with positions interacting with the binding partner or with cellular components. Population genetic analysis in humans revealed a complex scenario of local (FASLG, CD40LG, HAVCR2) and worldwide (FAS, ICOSLG) adaptation and H. sapiens-to-Neandertal gene flow (gene transfer between populations). Disease variants in these genes are preferential targets of pathogen-driven selection, and a Crohn’s disease risk polymorphism targeted by bacterial-driven selection modulates the expression of ICOSLG in response to a bacterial superantigen. Therefore, we used evolutionary information to generate experimentally testable hypotheses concerning the function of specific genetic variants and indicate that adaptation to infection underlies the maintenance of autoimmune risk alleles.