Microglia, the brain’s resident macrophages, help to regulate brain function by removing dying neurons, pruning non-functional synapses, and producing ligands that support neuronal survival1. Here we show that microglia are also critical modulators of neuronal activity and associated behavioural responses in mice. Microglia respond to neuronal activation by suppressing neuronal activity, and ablation of microglia amplifies and synchronizes the activity of neurons, leading to seizures. Suppression of neuronal activation by microglia occurs in a highly region-specific fashion and depends on the ability of microglia to sense and catabolize extracellular ATP, which is released upon neuronal activation by neurons and astrocytes. ATP triggers the recruitment of microglial protrusions and is converted by the microglial ATP/ADP hydrolysing ectoenzyme CD39 into AMP; AMP is then converted into adenosine by CD73, which is expressed on microglia as well as other brain cells. Microglial sensing of ATP, the ensuing microglia-dependent production of adenosine, and the adenosine-mediated suppression of neuronal responses via the adenosine receptor A1R are essential for the regulation of neuronal activity and animal behaviour. Our findings suggest that this microglia-driven negative feedback mechanism operates similarly to inhibitory neurons and is essential for protecting the brain from excessive activation in health and disease.