Nitrogen fixation by the cyanobacterium Anabaena is carried out in heterocysts, specialized, non-dividing cells which differentiate under conditions of ammonia or nitrate deprivation. In Anabaena, heterocyst differentiation is accompanied by rearrangement of some nitrogen fixation genes. A site-specific recombination between an 11 base-pair direct repeat sequence flanking the nifK and nifD genes removes 11 kilobases of intervening DNA, resulting in juxtaposition of the two genes and an alteration of the nifD protein-coding sequence.