In the human gut microbiome, specific strains emerge due to within-host evolution and can occasionally be transferred to or from other hosts. Phenotypic variance among such strains can have implications for strain transmission and interaction with the host. Surveilling strains of the same species, within and between individuals, can further our knowledge about the way in which microbial diversity is generated and maintained in host populations. Existing methods to estimate the biological relatedness of similar strains usually rely on either detection of single nucleotide polymorphisms (SNP), which may include sequencing errors, or on the analysis of pangenomes, which can be limited by the requirement for extensive gene databases. To complement existing methods, we developed SynTracker. This strain-comparison tool is based on synteny comparisons between strains, or the comparison of the arrangement of sequence blocks in two homologous genomic regions in pairs of metagenomic assemblies or genomes. Our method is executed in a species-specific manner, has a low sensitivity to SNPs, does not require a pre-existing database, and can correctly resolve strains using complete or draft genomes and metagenomic samples using <5% of the genome length. When applied to metagenomic datasets, we detected person-specific strains with an average sensitivity of 97% and specificity of 99%, and strain-sharing events in mother-infant pairs. SynTracker can be used to study the population structure of specific microbial species between and within environments, to identify evolutionary trajectories in longitudinal datasets, and to further understanding of strain sharing networks.