Interleukin (IL)-17a has been highly conserved during evolution of the vertebrate immune system and widely studied in contexts of infection and autoimmunity. Studies suggest that IL-17a promotes behavioral changes in experimental models of autism and aggregation behavior in worms. Here, through a cellular and molecular characterization of meningeal γδ17 T cells, we defined the nearest central nervous system–associated source of IL-17a under homeostasis. Meningeal γδ T cells express high levels of the chemokine receptor CXCR6 and seed meninges shortly after birth. Physiological release of IL-17a by these cells was correlated with anxiety-like behavior in mice and was partially dependent on T cell receptor engagement and commensal-derived signals. IL-17a receptor was expressed in cortical glutamatergic neurons under steady state and its genetic deletion decreased anxiety-like behavior in mice. Our findings suggest that IL-17a production by meningeal γδ17 T cells represents an evolutionary bridge between this conserved anti-pathogen molecule and survival behavioral traits in vertebrates.