Published polymerase chain reaction primer sets for detecting the genes encoding 16S rRNA gene and hydrazine oxidoreductase (hzo) in anammox bacteria were compared by using the same coastal marine sediment samples. While four previously reported primer sets developed to detect the 16S rRNA gene showed varying specificities between 12% and 77%, an optimized primer combination resulted in up to 98% specificity, and the recovered anammox 16S rRNA gene sequences were >95% sequence identical to published sequences from anammox bacteria in the Candidatus "Scalindua" group. Furthermore, four primer sets used in detecting the hzo gene of anammox bacteria were highly specific (up to 92%) and efficient, and the newly designed primer set in this study amplified longer hzo gene segments suitable for phylogenetic analysis. The optimized primer set for the 16S rRNA gene and the newly designed primer set for the hzo gene were successfully applied to identify anammox bacteria from marine sediments of aquaculture zone, coastal wetland, and deep ocean where the three ecosystems form a gradient of anthropogenic impact. Results indicated a broad distribution of anammox bacteria with high niche-specific community structure within each marine ecosystem.