Dimethylsulfoniopropionate (DMSP) is a globally important organosulfur molecule and the major precursor for dimethyl sulfide. These compounds are important info-chemicals, key nutrients for marine microorganisms, and are involved in global sulfur cycling, atmospheric chemistry and cloud formation1-3. DMSP production was thought to be confined to eukaryotes, but heterotrophic bacteria can also produce DMSP through the pathway used by most phytoplankton4, and the DsyB enzyme catalysing the key step of this pathway in bacteria was recently identified5. However, eukaryotic phytoplankton probably produce most of Earth's DMSP, yet no DMSP biosynthesis genes have been identified in any such organisms. Here we identify functional dsyB homologues, termed DSYB, in many phytoplankton and corals. DSYB is a methylthiohydroxybutryate methyltransferase enzyme localized in the chloroplasts and mitochondria of the haptophyte Prymnesium parvum, and stable isotope tracking experiments support these organelles as sites of DMSP synthesis. DSYB transcription levels increased with DMSP concentrations in different phytoplankton and were indicative of intracellular DMSP. Identification of the eukaryotic DSYB sequences, along with bacterial dsyB, provides the first molecular tools to predict the relative contributions of eukaryotes and prokaryotes to global DMSP production. Furthermore, evolutionary analysis suggests that eukaryotic DSYB originated in bacteria and was passed to eukaryotes early in their evolution.