Increases in brain blood flow, evoked by neuronal activity, power neural computation and form the basis of BOLD (blood-oxygen-level-dependent) functional imaging. Whether blood flow is controlled solely by arteriole smooth muscle, or also by capillary pericytes, is controversial. We demonstrate that neuronal activity and the neurotransmitter glutamate evoke the release of messengers that dilate capillaries by actively relaxing pericytes. Dilation is mediated by prostaglandin E2, but requires nitric oxide release to suppress vasoconstricting 20-HETE synthesis. In vivo, when sensory input increases blood flow, capillaries dilate before arterioles and are estimated to produce 84% of the blood flow increase. In pathology, ischaemia evokes capillary constriction by pericytes. We show that this is followed by pericyte death in rigor, which may irreversibly constrict capillaries and damage the blood-brain barrier. Thus, pericytes are major regulators of cerebral blood flow and initiators of functional imaging signals. Prevention of pericyte constriction and death may reduce the long-lasting blood flow decrease that damages neurons after stroke.