Melatonin (Mel) and its receptors are promising for glycaemic control in patients with type 2 diabetes mellitus (T2DM) and its complications, but there is significant heterogeneity among studies. This study aims to investigate the effects of Mel receptor agonist Neu-P11 on glucose metabolism, immunity, and islet function in T2DM rats. In this study, SD rats were treated with a high-fat diet and streptozotocin (STZ) to establish a T2DM model. The glucose oxidase method was used to measure blood glucose levels. Glucose and insulin tolerance tests were used to assess glucose metabolism. Haematoxylin-eosin staining was used to observe pancreatic tissue injury. The apoptosis of isletβ cells was analysed by TUNEL and insulin staining. Reactive oxygen species (ROS) levels and immune cell expression were analysed by flow cytometry. IF was used to analyse the activation of microglia. The immunoglobulins: IgA, IgG, IgM, tumour necrosis factorα (TNF-α), interleukins IL-10 and IL-1β, interferonγ (IFN-γ), C-peptide, and insulin levels were determined by ELISA. The expression of CD11b, CD86, cleaved caspase 3, p21, and P16 proteins were analysed by western blot. The results showed that the blood glucose level increased, insulin resistance occurred, spleen coefficient and ROS levels increased, humoral immunity in peripheral blood decreased, and inflammation increased in the model group compared to the control group. After Mel and Neu-P11 treatment, the blood glucose level decreased significantly, insulin sensitivity improved, spleen coefficient and ROS levels decreased, humoral immunity in peripheral blood was enhanced, and inflammation improved in T2DM rats. Brain functional analysis of T2DM rats showed that microglia cells were activated, TNF-α and IL-β levels were increased, and IL-10 levels were decreased. Mel and Neu-P11 treatment reversed these indexes. Functional analysis of islets in T2DM rats showed that islet structure inflammation was impaired, isletβ cells were apoptotic, p21 and p16 protein expressions were increased, and blood C-peptide and insulin were decreased. Mel and Neu-P11 treatment restored the function of pancreatic b cells and improved the damage of pancreatic tissue. Melatonin and its receptor Neu-P11 can reduce the blood glucose level, enhance humoral and cellular immunity, inhibit microglia activation and inflammation, and repair isletβ cell function, and this improve the characterization of T2DM-related diseases.