The cystic cavity that develops following injuries to brain or spinal cord is a major obstacle for tissue repair in central nervous system (CNS). Here we report that injection of imidazole-poly(organophosphazenes) (I-5), a hydrogel with thermosensitive sol–gel transition behavior, almost completely eliminates cystic cavities in a clinically relevant rat spinal cord injury model. Cystic cavities are bridged by fibronectin-rich extracellular matrix. The fibrotic extracellular matrix remodeling is mediated by matrix metalloproteinase-9 expressed in macrophages within the fibrotic extracellular matrix. A poly(organophosphazenes) hydrogel lacking the imidazole moiety, which physically interacts with macrophages via histamine receptors, exhibits substantially diminished bridging effects. I-5 injection improves coordinated locomotion, and this functional recovery is accompanied by preservation of myelinated white matter and motor neurons and an increase in axonal reinnervation of the lumbar motor neurons. Our study demonstrates that dynamic interactions between inflammatory cells and injectable biomaterials can induce beneficial extracellular matrix remodeling to stimulate tissue repair following CNS injuries.