Ergothioneine is an emerging factor in cellular redox homeostasis in bacteria, fungi, plants, and animals. Reports that ergothioneine biosynthesis may be important for the pathogenicity of bacteria and fungi raise the question as to how this pathway is regulated and whether the corresponding enzymes may be therapeutic targets. The first step in ergothioneine biosynthesis is catalyzed by the methyltransferase EgtD that converts histidine into N-α-trimethylhistidine. This report examines the kinetic, thermodynamic and structural basis for substrate, product, and inhibitor binding by EgtD from Mycobacterium smegmatis. This study reveals an unprecedented substrate binding mechanism and a fine-tuned affinity landscape as determinants for product specificity and product inhibition. Both properties are evolved features that optimize the function of EgtD in the context of cellular ergothioneine production. On the basis of these findings, we developed a series of simple histidine derivatives that inhibit methyltransferase activity at low micromolar concentrations. Crystal structures of inhibited complexes validate this structure- and mechanism-based design strategy.