Magnetotactic bacteria (MTB), which can mineralize nanosized magnetite or greigite crystals within cells, play important roles in biogeochemical processes, for example iron and sulfur cycling, and depositional remanent magnetization acquisitions. Despite decades of research, the knowledge of MTB distribution and ecology is still limited. In the present study, we investigated the temporal variation of MTB communities in freshwater sediment microcosms based on 16S rRNA genes and unifrac analyses. Two microcosms (MY8 and MY11) collected from two separate sites in Lake Miyun (Beijing, China) were analyzed. The majority of retrieved sequences belonged to alphaproteobacterial magnetotactic cocci in both microcosms (representing 64.29% of clones from MY8 and 100% of clones from MY11), whereas so-called ‘Magnetobacterium bavaricum’-like MTB affiliated within Nitrospira phylum were exclusively found in microcosm MY8. Over a 3-month period, the temporal variation of MTB communities was evident in both microcosms. In addition, the phylogenetic discrepancy of MTB communities between two microcosms is more prominent than that of the same microcosm at different times, implying adaptation of MTB phylogenetic lineages to specific microenvironments. Among the physical–chemical parameters measured, a strong correlation was shown between nitrate and the main genetic variability of MTB communities, indicating that nitrate may influence the occurrence of MTB phylogenetic lineages in natural environments.