The increasing incidence of intractable ulcerative colitis (UC) necessitates the development of targeted therapeutics. Herein, we developed a gallic acid (GA)-based nanoparticle that forms a hydrogel with GA-functionalized pectin (PG) in situ within the intestine for targeted cohesion and enhanced local drug delivery. The nanoparticle is composed of bioactive berberine (BBR) and GA. In the presence of intestinal enzymes, the GA nanoparticle covalently crosslinks with PG to form a hydrogel in the intestine after oral administration. This bioactive, mucoadhesive drug delivery system is engineered to exert multiple therapeutic effects, including anti-inflammatory and antioxidant activities, radical scavenging, and restoration of immune and microbiota homeostasis, while also strengthening the epithelial barrier. This multifunctional hydrogel system marks a significant advancement in the localized treatment of UC, offering a new approach to managing complex gastrointestinal conditions.