Polychaetes play a vital role in the structure and functioning of benthic communities in mangrove ecosystems. Nevertheless, our understanding of the diversity and functional structure of polychaete assemblages across different habitats in the mangrove ecosystems along the coast of the Persian Gulf and Gulf of Oman is limited. In this study, we investigated the species and trait composition of polychaetes and environmental variables, in vegetated and mudflat habitats of three subtropical mangroves. The results showed that Neanthes glandicincta was widely distributed across all regions and habitats. The three-factor ANOVA showed that the abundance and taxonomic diversity of polychaetes differed significantly between two habitats and three mangrove ecosystems. The abundance of polychaetes was observed to be higher in mud habitats than in vegetated habitats. There was a significant difference in species and trait composition between different regions and habitats. Vegetated habitats had higher proportions of crawler predatory species that are longer lived (3–5 years), with larger body size (80–100 mm), and are upward conveyors, whereas mudflat habitats had higher proportions of mobile (burrower) omnivore species that are moderately lived (1–3 years), with larger body size (>100 mm), and are biodiffusers. The three-factor ANOVA showed a significant difference in the community weighted mean (CWM) index between two habitats and three mangrove ecosystems. Thus, the species and trait composition of polychaetes depend on the structural complexity of their respective habitats. The DistLM analysis showed that total organic carbon content of the sediment was the main predictor variable influencing species composition, while silt/clay content and salinity were the main predictor variables influencing the traits’ composition. The results showed how the composition of traits and the structure of polychaete communities change in mangrove ecosystems, which can be used for future studies on conservation strategies for mangrove ecosystems throughout the world.