Carbon dioxide (CO2), the major product of metabolism, has a strong impact on cerebral blood vessels, a phenomenon known as cerebrovascular reactivity. Several vascular risk factors such as hypertension or diabetes dampen this response, making cerebrovascular reactivity a useful diagnostic marker for incipient vascular pathology, but its functional relevance, if any, is still unclear. Here, we found that GPR4, an endothelial H+ receptor, and endothelial Gαq/11 proteins mediate the CO2/H+ effect on cerebrovascular reactivity in mice. CO2/H+ leads to constriction of vessels in the brainstem area that controls respiration. The consequential washout of CO2, if cerebrovascular reactivity is impaired, reduces respiration. In contrast, CO2 dilates vessels in other brain areas such as the amygdala. Hence, an impaired cerebrovascular reactivity amplifies the CO2 effect on anxiety. Even at atmospheric CO2 concentrations, impaired cerebrovascular reactivity caused longer apneic episodes and more anxiety, indicating that cerebrovascular reactivity is essential for normal brain function. The site-specific reactivity of vessels to CO2 is reflected by regional differences in their gene expression and the release of vasoactive factors from endothelial cells. Our data suggest the central nervous system (CNS) endothelium as a target to treat respiratory and affective disorders associated with vascular diseases.