Methylphosphonate synthase (MPnS) produces methylphosphonate, a metabolic precursor to methane in the upper ocean. Here, we determine a 2.35-angstrom resolution structure of MPnS and discover that it has an unusual 2-histidine-1-glutamine iron-coordinating triad. We further solve the structure of a related enzyme, hydroxyethylphosphonate dioxygenase from Streptomyces albus (SaHEPD), and find that it displays the same motif. SaHEPD can be converted into an MPnS by mutation of glutamine-adjacent residues, identifying the molecular requirements for methylphosphonate synthesis. Using these sequence markers, we find numerous putative MPnSs in marine microbiomes and confirm that MPnS is present in the abundant Pelagibacter ubique. The ubiquity of MPnS-containing microbes supports the proposal that methylphosphonate is a source of methane in the upper, aerobic ocean, where phosphorus-starved microbes catabolize methylphosphonate for its phosphorus.