Cognitive dysfunction has been regarded as a complication of diabetes. Melatonin (MLT) shows a neuroprotective effect on various neurological diseases. However, its protective effect on cortical neurons in high glucose environment has not been reported. Our present study aims to observe the protective effect of melatonin on rat cortical neurons and its relationship with autophagy in high glucose environment. The rat primary cortical neurons injury model was induced by high glucose. The CCK-8, flow cytometry, Western blot and immunofluorescence methods were used to examine the cell viability, apoptosis rate and proteins expression. Our results showed that there were no differences in cell viability, apoptosis rate, and protein expression among the control, MLT and mannitol group. The cell viability of the glucose group was significantly lower than that of the control group, and the apoptosis rate of the glucose group was significantly higher than that of the control group. Compared with the glucose group, the glucose + melatonin group showed a significant increase in cell viability and a notable decrease in apoptosis rate. Melatonin concentration of 0.1–1 mmol/L can significantly alleviate the injury of cortical neurons caused by high glucose. Compared with the control group, the glucose group showed a significant reduction of B-cell lymphoma 2 (Bcl-2) protein expression, while remarkable elevations of Bcl2-associated X protein (Bax), cleaved Caspase-3, coiled-coil, myosin-like Bcl2-interacting protein (Beclin-1) and microtubule-associated protein 1 light chain-3B type II (LC3B-II) levels. The neurons pre-administered with melatonin obtained significantly reversed these changes induced by high glucose. The phosphorylation levels of protein kinase B (Akt), mechanistic target of rapamycin kinase (mTOR) and Unc-51 like autophagy activating kinase 1(ULK1) were decreased in the glucose group compared with the control group, whereas significant increase were observed in the glucose + MLT group, compared with the glucose group. These data indicated that melatonin has a neuroprotective effect on cortical neurons under high glucose environment, which may work by activating Akt/mTOR/ULK1 pathway and may be deeply associated with the downregulation of autophagy.