Tara gum (TG) was derivatized to carboxymethyl TG (CMTG) and then cross-linked with Al3+/Ca2+ ions to prepare Al/Ca cross-linked CMTG matrices for sustained delivery of Tramadol Hydrochloride (TH), a highly water-soluble drug. The effect of Al3+/Ca2+ ions concentration on swelling, erosion, and drug release behavior from Al/Ca-CMTG matrices was investigated. Al-CMTG matrices had greater cross-linking density, produced a more rigid and denser hydrogel layer than Ca-CMTG matrices. The rate of swelling, erosion, and in vitro drug release from Al-CMTG matrices was slower than from Ca-CMTG matrices. The most important finding of our study indicated that at the same concentration of cross-linking ions, the release of TH from Al-CMTG matrices was slower compared to Ca-CMTG matrices. The optimized formulation containing 9 % w/w AlCl3 in CMTG matrices released TH in a sustained manner up to 12 h in the gastrointestinal milieu. Moreover, it was observed that the prepared optimized formulation exhibited a more sustained release of TH compared to the marketed product.