Ergothioneine (EGT) is synthesized in mycobacteria, but limited knowledge exists regarding its synthesis, physiological role, and regulation. We have identified Rv3701c from Mycobacterium tuberculosis to encode for EgtD, a required histidine methyltransferase that catalyzes first biosynthesis step in EGT biosynthesis. EgtD was found to be phosphorylated by the serine/threonine protein kinase PknD. PknD phosphorylates EgtD both in vitro and in a cell-based system on Thr213. The phosphomimetic (T213E) but not the phosphoablative (T213A) mutant of EgtD failed to restore EGT synthesis in a ΔegtD mutant. The findings together with observed elevated levels of EGT in a pknD transposon mutant during in vitro growth suggests that EgtD phosphorylation by PknD negatively regulates EGT biosynthesis. We further showed that EGT is required in a nutrientstarved model of persistence and is needed for long term infection of murine macrophages.