Marine algae and bacteria produce eight billion tonnes of the organosulfur molecule dimethylsulfoniopropionate (DMSP) in Earth’s surface oceans every year. DMSP is an anti-stress compound and, once released into the environment, a major nutrient, signalling molecule and source of climate-active gases. The methionine transamination pathway for DMSP synthesis is used by most known DMSP-producing algae and bacteria. The S-directed S-adenosylmethionine-dependent methyltransferase (SAM-MT) 4-methylthio-2-hydroxybutyrate (MTHB) S-methyltransferase, encoded by the dsyB/DSYB gene, is the key enzyme of this pathway, generating S-adenosylhomocysteine (SAH) and 4-dimethylsulfonio-2-hydroxybutyrate (DMSHB). dsyB/DSYB, present in most DMSP-producing bacteria and haptophyte and dinoflagellate algae with the highest known DMSP concentrations, is shown to be far more abundant and transcribed in marine environments than any other known DMSP synthesis pathway S-methyltransferase gene. Furthermore, we demonstrate in vitro activity of the bacterial DsyB enzyme from Nisaea denitrificans, and provide its crystal structure in complex with SAM and SAH-MTHB, which together provide the first mechanistic insights into a DMSP synthesis enzyme. Structural and mutational analyses imply that DsyB adopts a novel mechanism, distinct from any previously reported SAM-MT, in which the DsyB residue Tyr142 activates the sulfur atom of MTHB for nucleophilic attack on the SAM methyl group. Sequence analysis suggests that this mechanism is common to all bacterial DsyB enzymes and also, importantly, eukaryotic DSYB enzymes from e.g., algae that are the major DMSP producers in Earth’s surface oceans.