In this paper, we describe a detailed study on preparation and characterizations of functional ionic liquid-gels and hydrogels of xanthan gum. When the 9.1-50.0 wt% solutions of xanthan gum in an ionic liquid, 1-butyl-3-methylimidazolium chloride (BMIMCl), were left standing at room temperature, they completely turned into gel forms. The obtained xanthan gum/BMIMCl gels showed good mechanical properties and thermally induced shape-memory effect. The formation of specific association of BMIMCl in the gels, which was constructed on the basis of the regularly ordered interaction of the imidazolium counter cations of xanthan gum with other BMIMCl molecules because of the rigidity of its main-chain, was suggested as a reason for the production of such unique gels. Furthermore, the 9.1 wt% xanthan gum/BMIMCl gel was converted into the xanthan gum hydrogel by soaking it in water, which showed good elasticity under compression. Moreover, ion-exchanged xanthan gum hydrogels with Na+, Ca2+, and Fe3+ were prepared. The ion-exchanged hydrogel with Ca2+ exhibited better mechanical properties both under compressive and tensile modes compared with the hydrogel with Na+, probably due to ionic cross-linking. However, the hydrogel with Fe3+ showed hard and brittle natures. Moreover, the reversible swelling-shrinking behaviors of the ion-exchanged hydrogels with Na+ and Ca2+ were clearly demonstrated to reveal their salt concentration-induced responsive properties.