In this study, the cationic monomer [2-(acryloyloxy)ethyl]trimethylammonium chloride solution (AETAC) and vinyl imidazole (VI) were used with the free radical polymerization technique, which is a simple and rapid synthesis method, to synthesize p(AETAC-co-VI) hydrogels. To increase the density of cationic charge on the hydrogel, it underwent the protonation process with HCl. The obtained p(AETAC-co-VI)/Q hydrogel was modified with Au nanoparticles to increase bactericidal effect to obtain the AuNPs/p(AETAC-co-VI)/Q nanocomposite hydrogel. The morphology and chemical structure of the hydrogels were characterized with SEM and FTIR. Additionally, the swelling capabilities were tested in different pH media. XRD and TEM confirmed the formation of the nanocomposite hydrogel. The antibacterial activity of the hydrogels was tested against E. coli and S. aureus, and controlled release implementations were completed with sodium diclofenac (NaDc) drug. The NaDc drug release profiles of the hydrogels were researched using the Korsmeyer-Peppas model at 37 degrees C in different simulated buffer (pH 6.0, 7.2, and 8.0) solutions. It was found that both the hydrogel and nanocomposite hydrogel followed non-Fickian diffusion mechanisms as free release mechanism. Here, the maximum drug release efficacy was found to be 97%, and drug release was more rapid in basic media when release media were compared. The AuNPs/p(AETAC-co-VI)/Q nanocomposite hydrogels produced in this study with advanced antibacterial features were suitable for recommendation as good carriers for in vitro release of NaDc drugs in areas like the biomedical and pharmaceutical industries.