Macrophages are diverse immune cells that reside in all tissues. Although macrophages have been implicated in mammary-gland function, their diversity has not been fully addressed. By exploiting high-resolution three-dimensional imaging and flow cytometry, we identified a unique population of tissue-resident ductal macrophages that form a contiguous network between the luminal and basal layers of the epithelial tree throughout postnatal development. Ductal macrophages are long lived and constantly survey the epithelium through dendrite movement, revealed via advanced intravital imaging. Although initially originating from embryonic precursors, ductal macrophages derive from circulating monocytes as they expand during puberty. Moreover, they undergo proliferation in pregnancy to maintain complete coverage of the epithelium in lactation, when they are poised to phagocytose milk-producing cells post-lactation and facilitate remodelling. Interestingly, ductal macrophages strongly resemble mammary tumour macrophages and form a network that pervades the tumour. Thus, the mammary epithelium programs specialized resident macrophages in both physiological and tumorigenic contexts.