Current data from bacterial pathogens of animals and from bacterial symbionts of plants support some of the more general proposed functions for lipopolysaccharides (LPS) and underline the importance of LPS structural versatility and adaptability. Most of the structural heterogeneity of LPS molecules is found in the O-antigen polysaccharide. In this review, the role and mechanisms of this striking flexibility in molecular structure of the O-antigen in bacterial pathogens and symbionts are illustrated by some recent findings. The variation in O-antigen that gives rise to an enormous structural diversity of O-antigens lies in the sugar composition and the linkages between monosaccharides. The chemical composition and structure of the O-antigen is strain-specific (interstrain LPS heterogeneity) but can also vary within one bacterial strain (intrastrain LPS heterogeneity). Both LPS heterogeneities can be achieved through variations at different levels. First of all, O-polysaccharides can be modified non-stoichiometrically with sugar moieties, such as glucosyl and fucosyl residues. The addition of non-carbohydrate substituents, i.e. acetyl or methyl groups, to the O-antigen can also occur with regularity, but in most cases these modifications are again non-stoichiometric. Understanding LPS structural variation in bacterial pathogens is important because several studies have indicated that the composition or size of the O-antigen might be a reliable indicator of virulence potential and that these important features often differ within the same bacterial strain. In general, O-antigen modifications seem to play an important role at several (at least two) stages of the infection process, including the colonization (adherence) step and the ability to bypass or overcome host defense mechanisms. There are many reports of modifications of O-antigen in bacterial pathogens, resulting either from altered gene expression, from lysogenic conversion or from lateral gene transfer followed by recombination. In most cases, the mechanisms underlying these changes have not been resolved. However, in recent studies some progress in understanding has been made. Changes in O-antigen structure mediated by lateral gene transfer, O-antigen conversion and phase variation, including fucosylation, glucosylation, acetylation and changes in O-antigen size, will be discussed. In addition to the observed LPS heterogeneity in bacterial pathogens, the structure of LPS is also altered in bacterial symbionts in response to signals from the plant during symbiosis. It appears to be part of a molecular communication between bacterium and host plant. Experiments ex planta suggest that the bacterium in the rhizosphere prepares its LPS for its roles in symbiosis by refining the LPS structure in response to seed and root compounds and the lower pH at the root surface. Moreover, modifications in LPS induced by conditions associated with infection are another indication that specific structures are important. Also during the differentiation from bacterium to bacteroid, the LPS of Rhizobium undergoes changes in the composition of the O-antigen, presumably in response to the change of environment. Recent findings suggest that, during symbiotic bacteroid development, reduced oxygen tension induces structural modifications in LPS that cause a switch from predominantly hydrophilic to predominantly hydrophobic molecular forms. However, the genetic mechanisms by which the LPS epitope changes are regulated remain unclear. Finally, the possible roles of O-antigen variations in symbiosis will be discussed.