Abstract Fast forming hydrogels prepared by crosslinking a poly(ethylene glycol) (PEG)-based copolymer containing multiple thiol (SH) groups were evaluated for the controlled ocular delivery of pilocarpine and subsequent pupillary constriction. Physical properties of the hydrogels were characterized using UV–Vis spectrophotometry, transmission electron microscopy (TEM), rheometry, and swelling kinetics. Pilocarpine loading efficiency and release properties were measured in simulated tear fluid. The hydrogel formulations exhibited high drug loading efficiency (~ 74%). Pilocarpine release was found to be biphasic with release half times of ~ 2 and 94 h, respectively, and 85–100% of the drug was released over 8-days. Pilocarpine-loaded (2% w/v) hydrogels were evaluated in a rabbit model and compared to a similar dose of drug in aqueous solution. The hydrogels were retained in the eye for the entire period of the study with no observed irritation. Pilocarpine-loaded hydrogels sustained pupillary constriction for 24 h after administration as compared to 3 h for the solution, an 8-fold increase in the duration of action. A strong correlation between pilocarpine release and pupillary response was observed. In conclusion, the current studies demonstrate that in situ forming PEG hydrogels possess the viscoelastic, retention, and sustained delivery properties required for an efficient ocular drug delivery system.