Heterotrophic activity, primarily driven by sulfate-reducing prokaryotes, has traditionally been linked to nitrogen fixation in the root zone of coastal marine plants, leaving the role of chemolithoautotrophy in this process unexplored. Here, we show that sulfur oxidation coupled to nitrogen fixation is a previously overlooked process providing nitrogen to coastal marine macrophytes. In this study, we recovered 239 metagenome-assembled genomes from a salt marsh dominated by the foundation plant Spartina alterniflora, including diazotrophic sulfate-reducing and sulfur-oxidizing bacteria. Abundant sulfur-oxidizing bacteria encode and highly express genes for carbon fixation (RuBisCO), nitrogen fixation (nifHDK) and sulfur oxidation (oxidative-dsrAB), especially in roots stressed by sulfidic and reduced sediment conditions. Stressed roots exhibited the highest rates of nitrogen fixation and expression level of sulfur oxidation and sulfate reduction genes. Close relatives of marine symbionts from the Candidatus Thiodiazotropha genus contributed ~30% and ~20% of all sulfur-oxidizing dsrA and nitrogen-fixing nifK transcripts in stressed roots, respectively. Based on these findings, we propose that the symbiosis between S. alterniflora and sulfur-oxidizing bacteria is key to ecosystem functioning of coastal salt marshes.