We report the identification and sequence from Escherichia coli and Salmonella enterica strains of the cld gene, encoding the chain-length determinant (CLD) which confers a modal distribution of chain length on the O-antigen component of lipopolysaccharide (LPS). The distribution of chain lengths in the absence of this gene fits a model in which as the chain is extended there is a constant probability of 0.165 of transfer of growing chain to LPS core, with termination of chain extension. The data for E. coli O111 fit a model in which the CLD reduces this probability for short chains and increases it to 0.4 for longer chains, leading to a reduced number of short chain molecules but an increase in numbers of longer molecules and transfer of essentially all molecules by chain length 21. We put forward a model for O-antigen polymerase which resembles the ribosome and fatty acid synthetase in having two sites, with the growing chain being transferred from a D site onto the new unit at the R site to extend the chain and then back to the D site to repeat the process. It is proposed that the CLD protein and polymerase form a complex which has two states: 'E' facilitating extension and 'T' facilitating transfer to core. The complex is postulated to enter the E state as O-antigen polymerization starts, and to shift to the T state after a predetermined time, the CLD acting as a molecular clock. The CLD is not O-antigen or species-specific but the modal value does depend on the source of the cld gene.