This Review describes recent advances in our understanding of the ontogeny, development and function of brain-resident macrophages and microglia, including their normal functions during brain development and homeostasis and how disturbance of these functions may precipitate neurodegenerative and neuropsychiatric diseases.