Microglia have critical roles not only in neural development and homeostasis, but also in neurodegenerative and neuroinflammatory diseases of the central nervous system1-4. These highly diverse and specialized functions may be executed by subsets of microglia that already exist in situ, or by specific subsets of microglia that develop from a homogeneous pool of cells on demand. However, little is known about the presence of spatially and temporally restricted subclasses of microglia in the central nervous system during development or disease. Here we combine massively parallel single-cell analysis, single-molecule fluorescence in situ hybridization, advanced immunohistochemistry and computational modelling to comprehensively characterize subclasses of microglia in multiple regions of the central nervous system during development and disease. Single-cell analysis of tissues of the central nervous system during homeostasis in mice revealed specific time- and region-dependent subtypes of microglia. Demyelinating and neurodegenerative diseases evoked context-dependent subtypes of microglia with distinct molecular hallmarks and diverse cellular kinetics. Corresponding clusters of microglia were also identified in healthy human brains, and the brains of patients with multiple sclerosis. Our data provide insights into the endogenous immune system of the central nervous system during development, homeostasis and disease, and may also provide new targets for the treatment of neurodegenerative and neuroinflammatory pathologies.