Macrophages are immune cells of haematopoietic origin that provide crucial innate immune defence and have tissue-specific functions in the regulation and maintenance of organ homeostasis. Recent studies of macrophage ontogeny, as well as transcriptional and epigenetic identity, have started to reveal the decisive role of the tissue stroma in the regulation of macrophage function. These findings suggest that most macrophages seed the tissues during embryonic development and functionally specialize in response to cytokines and metabolites that are released by the stroma and drive the expression of unique transcription factors. In this Review, we discuss how recent insights into macrophage ontogeny and macrophage-stroma interactions contribute to our understanding of the crosstalk that shapes macrophage function and the maintenance of organ integrity.