A thermosensitive and injectable hydrogel composed of chitosan (CS), chitosan biguanide hydrochloride (CSG) and collagen (CO) could embed umbilical cord mesenchymal stem cells (UC-MSCs), then was applied for the type 2 diabetes mellitus (T2DM) treatment in vivo. UC-MSCs could adhere well on CS/CSG/CO hydrogel surface and cell division could be clearly observed. Especially, UC-MSCs maintained alive till they grew in CS/CSG/CO hydrogel for 8 days, while the amount of UC-MSCs was limited due to the steric hindrance in hydrogel. To T2DM mice contrastive treatment by intraperitoneal injection for thirteen weeks, UC-MSCs + Hydrogel group could improve the impaired glucose tolerance, maintain glucose homeostasis in vivo, and restore islet morphology for T2DM mice. The immunofluorescence staining and western blot experiments further displayed that both the nuclear antigen Ki67 for cell proliferation and pancreatic duodenal homeobox-1 (Pdx1) expression in UC-MSCs + Hydrogel group were significantly higher than the expressions in untreated T2DM group and treated UC-MSCs + PBS group, which indicated that UC-MSCs + Hydrogel elevated β cell transcriptional activity. Moreover, the positivity rates of iNOS and CD163 in UC-MSCs + Hydrogel group were generally decreased and increased, respectively, compared to those in untreated T2DM group and treated UC-MSCs + PBS group. It displayed that UC-MSCs + Hydrogel could reduce M1 macrophage expression and increase M2 macrophage polarization in T2DM mice.