The origin and evolution of magnetoreception, which in diverse prokaryotes and protozoa is known as magnetotaxis and enables these microorganisms to detect Earth’s magnetic field for orientation and navigation, is not well understood in evolutionary biology. The only known prokaryotes capable of sensing the geomagnetic field are magnetotactic bacteria (MTB), motile microorganisms that biomineralize intracellular, membrane-bounded magnetic single-domain crystals of either magnetite (Fe3O4) or greigite (Fe3S4) called magnetosomes. Magnetosomes are responsible for magnetotaxis in MTB. Here we report the first large-scale metagenomic survey of MTB from both northern and southern hemispheres combined with 28 genomes from uncultivated MTB. These genomes expand greatly the coverage of MTB in the Proteobacteria, Nitrospirae, and Omnitrophica phyla, and provide the first genomic evidence of MTB belonging to the Zetaproteobacteria and “Candidatus Lambdaproteobacteria” classes. The gene content and organization of magnetosome gene clusters, which are physically grouped genes that encode proteins for magnetosome biosynthesis and organization, are more conserved within phylogenetically similar groups than between different taxonomic lineages. Moreover, the phylogenies of core magnetosome proteins form monophyletic clades. Together, these results suggest a common ancient origin of iron-based (Fe3O4 and Fe3S4) magnetotaxis in the domain Bacteria that underwent lineage-specific evolution, shedding new light on the origin and evolution of biomineralization and magnetotaxis, and expanding significantly the phylogenomic representation of MTB.