Compatible solutes play a decisive role in the defense of microorganisms against changes in temperature and increases in osmolarity in their natural habitats. In Bacillus subtilis, the substrate-binding protein (SBP)-dependent ABC-transporter OpuA serves for the uptake of the compatible solutes glycine betaine (GB) and proline betaine (PB). Here, we report the determinants of compatible solute binding by OpuAC, the SBP of the OpuA transporter, by equilibrium binding studies and X-ray crystallography. The affinity of OpuAC/GB and OpuAC/PB complexes were analyzed by intrinsic tryptophan fluorescence and the K(D) values were determined to be 17(+/-1)microM for GB and 295(+/-27)microM for PB, respectively. The structures of OpuAC in complex with GB or PB were solved at 2.0 A and 2.8 A, respectively, and show an SBP-typical class II fold. The ligand-binding pocket is formed by three tryptophan residues arranged in a prism-like geometry suitable to coordinate the positive charge of the trimethyl ammonium group of GB and the dimethyl ammonium group of PB by cation-pi interactions and by hydrogen bonds with the carboxylate moiety of the ligand. Structural differences between the OpuAC/GB and OpuAC/PB complexes occur within the ligand-binding pocket as well as across the domain-domain interface. These differences provide a structural framework to explain the drastic differences in affinity of the OpuAC/GB and OpuAC/PB complexes. A sequence comparison with putative SBP specific for compatible solutes reveals the presence of three distinct families for which the crystal structure of OpuAC might serve as a suitable template to predict the structures of these putative compatible solute-binding proteins.