Type 2 diabetes mellitus (T2DM) is a risk factor for cognitive impairment. Ranolazine, an anti-ischemic drug used in the treatment of angina pectoris, has been shown to possess hypoglycemic properties in pre-clinical and clinical studies. The aim of this study was to evaluate the effects of ranolazine on glucose metabolism and cognitive function in a T2DM model of Wistar rats. Diabetes was induced by a high fat diet (HFD) and streptozotocin (STZ). The control group received a normal caloric diet (NCD) and sodium citrate buffer. Metformin, an effective hypoglycemic drug, was employed as a positive control. Animals were divided into the following groups: HFD/STZ + Ranolazine, HFD/STZ + Metformin, HFD/STZ + Vehicle, NCD + Vehicle, NCD + Ranolazine, and NCD + Metformin. Rats received ranolazine (20 mg/kg), metformin (300 mg/kg), or water, for 8 weeks. At the end of the treatments, all animals underwent to an intraperitoneal glucose tolerance test (IPGTT) and behavioral tests, including passive avoidance, novel object recognition, forced swimming, and elevate plus maze tests. Interleukin-6 plasma levels in the six treatment groups were assessed by Elisa assay. Body mass composition was estimated by nuclear magnetic resonance (NMR). Glucose responsiveness significantly improved in the HFD/STZ + Ranolazine (p < 0.0001) and HFD/STZ + Metformin (p = 0.003) groups. There was a moderate effect on blood glucose levels in the NCD + Ranolazine and NCD + Metformin groups. Lean body mass was significantly increased in the HFD/STZ + Ranolazine and HFD/STZ + Metformin animals, compared to HFD/STZ + Vehicle animals. Ranolazine improved learning and long-term memory in HFD/STZ + Ranolazine compared to HFD/STZ + Vehicle (p < 0.001) and ameliorated the pro-inflammatory profile of diabetic mice. These results support the hypothesis of a protective effect of ranolazine against cognitive decline caused by T2DM.