Dimethylsulfoniopropionate (DMSP) and its catabolite dimethyl sulfide (DMS) are key marine nutrients1,2 that have roles in global sulfur cycling2, atmospheric chemistry3, signalling4,5 and, potentially, climate regulation6,7. The production of DMSP was previously thought to be an oxic and photic process that is mainly confined to the surface oceans. However, here we show that DMSP concentrations and/or rates of DMSP and DMS synthesis are higher in surface sediment from, for example, saltmarsh ponds, estuaries and the deep ocean than in the overlying seawater. A quarter of bacterial strains isolated from saltmarsh sediment produced DMSP (up to 73 mM), and we identified several previously unknown producers of DMSP. Most DMSP-producing isolates contained dsyB8, but some alphaproteobacteria, gammaproteobacteria and actinobacteria used a methionine methylation pathway independent of DsyB that was previously only associated with higher plants. These bacteria contained a methionine methyltransferase gene (mmtN)—a marker for bacterial synthesis of DMSP through this pathway. DMSP-producing bacteria and their dsyB and/or mmtN transcripts were present in all of the tested seawater samples and Tara Oceans bacterioplankton datasets, but were much more abundant in marine surface sediment. Approximately 1 × 108 bacteria g−1 of surface marine sediment are predicted to produce DMSP, and their contribution to this process should be included in future models of global DMSP production. We propose that coastal and marine sediments, which cover a large part of the Earth’s surface, are environments with high levels of DMSP and DMS productivity, and that bacteria are important producers of DMSP and DMS within these environments.