Cholesterol and components of the cholesterol biosynthetic pathway have fundamental roles in all mammalian cells. Hydroxylated forms of cholesterol are now emerging as important regulators of immune function. This involves effects on the cholesterol biosynthetic pathway and cell membrane properties, which can have antiviral and anti-inflammatory influences. In addition, a dihydroxylated form of cholesterol functions as an immune cell guidance cue by engaging the G protein-coupled receptor EBI2, and it is required for mounting adaptive immune responses. In this Review, we summarize the current understanding of the closely related oxysterols 25-hydroxycholesterol and 7α,25-dihydroxycholesterol, and the growing evidence that they have wide-ranging influences on innate and adaptive immunity.