The solution structure is presented for the second family 4 carbohydrate binding module (CBM4-2) of xylanase 10A from the thermophilic bacterium Rhodothermus marinus. CBM4-2, which binds xylan tightly, has a beta-sandwich structure formed by 11 strands, and contains a prominent cleft. From NMR titrations, it is shown that the cleft is the binding site for xylan, and that the main amino acids interacting with xylan are Asn31, Tyr69, Glu72, Phe110, Arg115, and His146. Key liganding residues are Tyr69 and Phe110, which form stacking interactions with the sugar. It is suggested that the loops on which the rings are displayed can alter their conformation on substrate binding, which may have functional importance. Comparison both with other family 4 cellulose binding modules and with the structurally similar family 22 xylan binding module shows that the key aromatic residues are in similar positions, and that the bottom of the cleft is much more hydrophobic in the cellulose binding modules than the xylan binding proteins. It is concluded that substrate specificity is determined by a combination of ring orientation and the nature of the residues lining the bottom of the binding cleft.