SUMMARYCortical pathology contributes to chronic cognitive impairment of patients suffering from the neuroinflammatory disease multiple sclerosis (MS). How such gray matter inflammation affects neuronal structure and function is not well understood. Here we use functional and structural in vivo imaging in a mouse model of cortical MS to demonstrate that bouts of cortical inflammation disrupt cortical circuit activity coincident with a widespread but transient loss of dendritic spines. Spines destined for removal show a local calcium accumulation and are subsequently removed by invading macrophages and activated microglia. Targeting phagocyte activation with a new antagonist of the colony-stimulating factor 1 receptor prevents cortical synapse loss. Overall, our study identifies synapse loss as a key pathological feature of inflammatory gray matter lesions that is amenable to immunomodulatory therapy.HIGHLIGHTSWidespread, but transient loss of synapses in inflammatory lesions and beyondReversible impairment of neuronal firing and circuit function in the inflamed cortexCalcium dyshomeostasis of single spines precedes swift synapse lossPhagocyte-mediated spine pruning as targetable mechanism of synapse loss