Mycobacterium tuberculosis remains a leading cause of death worldwide, especially among individuals infected with HIV1. While phylogenetic analysis has revealed M. tuberculosis spread throughout history2–5 and in local outbreaks6–8, much less is understood about its dissemination within the body. Here, we report genomic analysis of 2693 samples collected postmortem from lung and extrapulmonary biopsies of 44 subjects in KwaZulu-Natal, South Africa who received minimal antitubercular treatment and most of whom were HIV seropositive. We found that purifying selection acted within individual patients, without the need for patient-to-patient transmission. Despite negative selection, mycobacteria diversified within individuals to form sub-lineages that co-existed for years. These sub-lineages, as well as distinct strains from mixed infections, were differentially distributed throughout the lung, suggesting temporary barriers to pathogen migration. As a consequence, samples taken from the upper airway often captured only a fraction of the population diversity, challenging current methods of outbreak tracing and resistance diagnostics. Phylogenetic analysis indicated that dissemination from the lungs to extrapulmonary sites was as frequent as between lung sites—supporting similar migration routes within and between organs, at least in subjects with HIV. Genomic diversity therefore provides a record of pathogen diversification and repeated dissemination across the body.