In this study, a pH- and temperature-responsive smart hydrogel was developed by utilizing Xanthan Gum (XG), N-Isopropylacrylamide (NIPAM), Vinyl Imidazole (VI), and Luffa cylindrical (LC). Semi-interpenetrating polymer networks (semi-IPNs) were created using free radical polymerization with N,N′-methylenebisacrylamide (MBA) as the cross-linker and ammonium persulfate (APS) as the initiator. Silver nanoparticles (AgNPs) were synthesized within semi-IPN hydrogel network structures to impart antibacterial properties. Malva sylvestris (MS) aqueous leaf extract was used as a reducing and stabilizing agent for the green synthesis of the AgNPs. The semi-IPN hydrogels exhibited pH- and temperature-responsive swelling behavior, which also enabled the controlled release of the drug. After 11 h, the cumulative release reached approximately 73% at pH 7.2 and 87% at pH 8.3. Additionally, the sustained release mechanism of the Trimethoprim drug was described using the Korsmeyer-Peppas model and was governed by Fickian diffusion. The drug-loaded semi-IPN@Ag nanocomposite hydrogel has demonstrated effective antibacterial activity against various Gram-negative and Gram-positive bacteria, indicating its promising potential as a wound dressing material for reducing infection risk.