The flagella of various Gram-negative bacteria are decorated with diverse glycan structures, amongst them nonulosonic acids related to the sialic acid family. Although nonulosonic sugar biosynthesis pathways have been dissected in various pathogens, the enzymes transferring the sugars onto flagellin are still poorly characterized. The deletion of genes coding for motility associated factors (Mafs) found in many pathogenic strains systematically gives rise to nonflagellated bacteria lacking specific nonulosonic sugars on the flagellins, therefore, relating Maf function to flagellin glycosylation and bacterial motility. We investigated the role of Maf from our model organism, Magnetospirillum magneticum AMB-1, in the glycosylation and formation of the flagellum. Deletion of the gene amb0685 coding for Maf produced a nonflagellated bacterium where the flagellin was still produced but no longer glycosylated. Our X-ray structure analysis revealed that the central domain of Maf exhibits similarity to sialyltransferases from Campylobacter jejuni. Glycan analysis suggested that the nonulosonic carbohydrate structure transferred is pseudaminic acid or a very close derivative. This work describes the importance of glycosylation in the formation of the bacterial flagellum and provides the first structural model for a member of a new bacterial glycosyltransferase family involved in nonulosonic acids transfer onto flagellins. © 2017 Society for Applied Microbiology and John Wiley & Sons Ltd.