Cationic small molecular biocides have been developed as promising antibiofilm agents because of their tunability in chemical structures and their ability to disrupt established biofilms. However, the impact of biocides in antibiofilm treatment is largely limited due to the lack of an effective delivery system that can ensure sustained release of biocides at the target site. Herein we report a biocide-encapsulated antibacterial and antibiofilm hydrogel that acts as an efficient delivery vehicle for the biocide and eradicates matured bacterial biofilm. The hydrogels are prepared using dextran methacrylate (Dex-MA), a biocompatible and photopolymerizable polymer, and a nontoxic cationic biocide with two cationic charges, two nonpeptidic amide bonds, and optimized amphiphilicity, which is capable of eradicating established bacterial biofilms. The gels, prepared via direct loading of the biocide and with highly controllable amounts, display 100% activity against both drug-sensitive and drug-resistant bacteria such as methicillin-resistant Staphylococcus aureus (MRSA). Importantly, the gels are shown to release the biocide and kill bacteria for an extended period of time (until day 5). When being treated with the established bacterial biofilms, the released biocide from the gel is shown to completely eradicate establishedS. aureus, Escherichia coli, and MRSA biofilms, the most common biofilm forming bacteria that cause severe infections (e.g., skin infections, urinary tract infections, etc.) in humans. Moreover, the gels were shown to annihilate preformed MRSA biofilm with >99.99% bacterial reduction under in vitro and in vivo conditions in a superficial MRSA infection model in mice. Notably, when tested, excellent skin compatibility is observed for these materials in various animal models such as a rat model of acute dermal toxicity, guinea pig model of skin sensitization, and rabbit model of skin irritation. The biocompatible antibacterial and antibiofilm hydrogels developed herein thus might be useful in treating bacterial biofilm associated infections, especially topical infections.