Poly((methacryloylamino)propyl trimethylammonium chloride-co-vinylimidazole) (p(MAPTAC-co-VI)) hydrogels were synthesized through free radical polymerization of 3-(methacryloylamino)propyl trimethylammonium chloride (MAPTAC) and 1-vinylimidazole (VI) in aqueous solutions with ammonium persulfate (APS) used as initiator and N,N '-methylenebis(acrylamide) (MBA) as the crosslinking agent. By modifying with HCl, the positive charge density on the hydrogel network structure was increased and quaternized hydrogels (p(MAPTAC-co-VI)-q) were obtained. Traditional swelling and spectrophotometric characterization techniques were used to gain a better understanding of the performance of cationic hydrogels for the removal of anionic dyes. FTIR, SEM, and EDX confirmed the structure of the hydrogel before and after the adsorption process. Later, dye adsorption performance of these p(MAPTAC-co-VI)-q hydrogels was investigated under different adsorption conditions, including initial concentration, temperature, pH values of dye solutions, and adsorption contact time, adsorbent dosage and in real water samples. Various isotherm and kinetic models of dye adsorption by the hydrogel were also studied and the experimental adsorption followed a pseudo-second order model and fitted the Langmuir isotherm well. Thanks to the effective use of existing adsorption sites, high adsorption capacity was achieved for eriochrome black T (EBT) and methyl orange (MO) dyes. The values of q(max) are as follows: 1818.2 mg/g and 1449.3 mg/g, respectively. Thermodynamic parameters indicate that the process was spontaneous and endothermic. P(MAPTAC-co-VI)-q hydrogels can be used as a potential adsorbent for removal of anionic dye molecules, one of the industrial pollutants, from wastewater.