Diabetes mellitus (DM) is a multisystem endocrine disorder affecting the brain. Mesenchymal stem cells (MSCs) pretreated with Melatonin have been shown to increase the potency of MSCs. This work aimed to compare Melatonin, stem cells, and stem cells pretreated with Melatonin on the cognitive functions and markers of synaptic plasticity in an animal model of type I diabetes mellitus (TIDM). Thirty-six rats represented the animal model; six rats for isolation of MSCs and 30 rats were divided into five groups: control, TIDM, TIDM + Melatonin, TIDM + Stem cells, and TIDM + Stem ex vivo Melatonin. Functional assessment was performed with Y-maze, forced swimming test and novel object recognition. Histological and biochemical evaluation of hippocampal Neuroligin 1, Sortilin, Brain-Derived Neurotrophic Factor (BDNF), inducible nitric oxide synthase (iNOS), toll-like receptor 2 (TLR2), Tumor necrosis factor-alpha (TNF-α), and Growth Associated Protein 43 (GAP43). The TIDM group showed a significant decrease of hippocampal Neuroligin, Sortilin, and BDNF and a significant increase in iNOS, TNF-α, TLR2, and GAP43. Melatonin or stem cells groups showed improvement compared to the diabetic group but not compared to the control group. TIDM + Stem ex vivo Melatonin group showed a significant improvement, and some values were restored to normal. Ex vivo melatonin-treated stem cells had improved spatial working and object recognition memory and depression, with positive effects on glucose homeostasis, inflammatory markers levels and synaptic plasticity markers expression.