In this study we have designed degenerate primers after comparative analysis of nifD gene sequences from public databases, and developed a PCR protocol for the amplification of nifD sequences from cyanobacteria. The primers were tested on a variety of nitrogenase-containing and nitrogenase-lacking bacteria. By using this protocol, we amplified nifD sequences from DNA that was isolated from three phototrophic microbial communities. Denaturing gradient gel electrophoresis (DGGE) and clone library analysis of the nifD amplicons showed the presence of distinct groups of diazotrophic cyanobacteria in each of the investigated microbial communities. Phylogenetic trees constructed from the sequences of nifD gene fragments are congruent with those based on ribosomal RNA gene sequences.