Imidazole-based polyamides (PA)s and polyimides (PI) s were prepared from condensation of a new aromatic heterocyclic diamine, 4,4›(4,4›-(2-(4-(triflouromethyl)phenyl)-1H-imidazole-4,5-dyl)bis(4,1-phenylen))bis(oxy)bis(3-(4,5-diphenyl-1H-imidazole-2-yl)aniline), with various diacids and dianhydrides, respectively. The structure of diamine, PAs and PIs were fully characterized by using elemental analysis, FT-IR, <sup>1</sup>H NMR and <sup>13</sup>C NMR techniques. Also, adsorption capability of these polymers for removal of heavy metal ions such as Co<sup>2+</sup>, Cr<sup>3+</sup>, Cd<sup>2+</sup>, Hg<sup>2+</sup> and Pb<sup>2+</sup> from aqueous solutions was also tested at pH 7-8. The PAs and PIs showed good solubility in aprotic polar organic solvents with high thermal stability exhibiting the glass transition temperatures (T<sub>g</sub>)s and 10% weight loss temperatures (T<sub>10</sub>%) in the range of 220-286 °C and 383-435 °C for PAs and 251-307 °C and 407-512 °C for PIs.