Recent studies have shown that the spatial turnover of bacterial communities, that is, beta-diversity, is determined by a combination of different assembly mechanisms, such as species sorting, that is, environmental filtering, and dispersal-related mechanisms. However, it is currently unclear to what extent the importance of the different mechanisms depends on community traits. Here, we implemented a study using a rock pool metacommunity to test whether habitat specialization of bacterial taxa and groups or their phylogenetic identity influenced by which mechanisms communities were assembled. In general, our results show that species sorting was the most important assembly mechanism. However, we found that a larger fraction of the variation in bacterial community composition between pools could be explained by environmental factors in case of habitat generalists, that is, taxa that were widespread and abundant in the metacommunity, compared with habitat specialists, that is, taxa that had a more restricted distribution range and tended to be rare. Differences in assembly mechanisms were observed between different major phyla and classes. However, also here, a larger fraction of the variation in community composition among pools could be explained for taxonomic groups that contained on average more habitat generalists. In summary, our results show that species sorting is stronger for the most common taxa, indicating that beta-diversity along environmental gradients can be adequately described without considering rare taxa.