The enzyme porphobilinogen deaminase (PBGD; hydroxymethylbilane synthase; EC 2.5.1.61) catalyses an early step of the tetrapyrrole-biosynthesis pathway in which four molecules of the monopyrrole porphobilinogen are condensed to form a linear tetrapyrrole. The enzyme possesses a dipyrromethane cofactor, which is covalently linked by a thioether bridge to an invariant cysteine residue (Cys241 in the Bacillus megaterium enzyme). The cofactor is extended during the reaction by the sequential addition of the four substrate molecules, which are released as a linear tetrapyrrole product. Expression in Escherichia coli of a His-tagged form of B. megaterium PBGD has permitted the X-ray analysis of the enzyme from this species at high resolution, showing that the cofactor becomes progressively oxidized to the dipyrromethene and dipyrromethanone forms. In previously solved PBGD structures, the oxidized cofactor is in the dipyromethenone form, in which both pyrrole rings are approximately coplanar. In contrast, the oxidized cofactor in the B. megaterium enzyme appears to be in the dipyrromethanone form, in which the C atom at the bridging -position of the outer pyrrole ring is very clearly in a tetrahedral configuration. It is suggested that the pink colour of the freshly purified protein is owing to the presence of the dipyrromethene form of the cofactor which, in the structure reported here, adopts the same conformation as the fully reduced dipyrromethane form.