Methylmercury is a potent neurotoxin produced in natural environments from inorganic mercury by anaerobic bacteria. However, until now the genes and proteins involved have remained unidentified. Here, we report a two-gene cluster, hgcA and hgcB, required for mercury methylation by Desulfovibrio desulfuricans ND132 and Geobacter sulfurreducens PCA. In either bacterium, deletion of hgcA, hgcB, or both genes abolishes mercury methylation. The genes encode a putative corrinoid protein, HgcA, and a 2[4Fe-4S] ferredoxin, HgcB, consistent with roles as a methyl carrier and an electron donor required for corrinoid cofactor reduction, respectively. Among bacteria and archaea with sequenced genomes, gene orthologs are present in confirmed methylators but absent in nonmethylators, suggesting a common mercury methylation pathway in all methylating bacteria and archaea sequenced to date.