Epstein-Barr virus-induced gene 2 (EBI2, also known as GPR183) is a G-protein-coupled receptor that is required for humoral immune responses; polymorphisms in the receptor have been associated with inflammatory autoimmune diseases. The natural ligand for EBI2 has been unknown. Here we describe the identification of 7α,25-dihydroxycholesterol (also called 7α,25-OHC or 5-cholesten-3β,7α,25-triol) as a potent and selective agonist of EBI2. Functional activation of human EBI2 by 7α,25-OHC and closely related oxysterols was verified by monitoring second messenger readouts and saturable, high-affinity radioligand binding. Furthermore, we find that 7α,25-OHC and closely related oxysterols act as chemoattractants for immune cells expressing EBI2 by directing cell migration in vitro and in vivo. A critical enzyme required for the generation of 7α,25-OHC is cholesterol 25-hydroxylase (CH25H). Similar to EBI2 receptor knockout mice, mice deficient in CH25H fail to position activated B cells within the spleen to the outer follicle and mount a reduced plasma cell response after an immune challenge. This demonstrates that CH25H generates EBI2 biological activity in vivo and indicates that the EBI2-oxysterol signalling pathway has an important role in the adaptive immune response.