Mycobacterium tuberculosis and Salmonella enterica cause very different diseases and are only distantly related. However, growth within macrophages is crucial for virulence in both of these intracellular pathogens. Here, we demonstrate that in spite of the phylogenetic distance, M. tuberculosis and Salmonella employ a parallel survival strategy for growth within macrophage phagosomes. Previous studies established that the Salmonella mgtC gene is required for growth within macrophages and for virulence in vivo. M. tuberculosis contains an open reading frame exhibiting 38% amino acid identity with the Salmonella MgtC protein. Upon inactivation of mgtC, the resulting M. tuberculosis mutant was attenuated for virulence in cultured human macrophages and impaired for growth in the lungs and spleens of mice. Replication of the mgtC mutant was inhibited in vitro by a combination of low magnesium and mildly acidic pH suggesting that the M. tuberculosis-containing phagosome has these characteristics. The similar phenotypes displayed by the mgtC mutants of M. tuberculosis and Salmonella suggest that the ability to acquire magnesium is essential for virulence in intracellular pathogens that proliferate within macrophage phagosomes.