Cell-based therapies are emerging as new promising treatments in stroke. However, their functional mechanism and therapeutic potential during early infarct maturation has so far received little attention. Here, we asked if cell-based delivery of the interleukin-1 receptor antagonist (IL-1Ra), a known neuroprotectant in stroke, can promote neuroprotection, by modulating the detrimental inflammatory response in the tissue at risk. We show by the use of IL-1Ra-overexpressing and IL-1Ra-deficient mice that IL-1Ra is neuroprotective in stroke. Characterization of the cellular and spatiotemporal production of IL-1Ra and IL-1α/β identifies microglia, not infiltrating leukocytes, as the major sources of IL-1Ra after experimental stroke, and shows IL-1Ra and IL-1β to be produced by segregated subsets of microglia with a small proportion of these cells co-expressing IL-1α. Reconstitution of whole body irradiated mice with IL-1Ra-producing bone marrow cells is associated with neuroprotection and recruitment of IL-1Ra-producing leukocytes after stroke. Neuroprotection is also achieved by therapeutic injection of IL-1Ra-producing bone marrow cells 30 min after stroke onset, additionally improving the functional outcome in two different stroke models. The IL-1Ra-producing bone marrow cells increase the number of IL-1Ra-producing microglia, reduce the availability of IL-1β, and modulate mitogen-activated protein kinase (MAPK) signaling in the ischemic cortex. The importance of these results is underlined by demonstration of IL-1Ra-producing cells in the human cortex early after ischemic stroke. Taken together, our results attribute distinct neuroprotective or neurotoxic functions to segregated subsets of microglia and suggest that treatment strategies increasing the production of IL-1Ra by infiltrating leukocytes or microglia may also be neuroprotective if applied early after stroke onset in patients.Electronic supplementary materialThe online version of this article (doi:10.1007/s00401-016-1541-5) contains supplementary material, which is available to authorized users.