Alzheimer's disease (AD) is the most prevalent type of dementia in elderly people. There are decreased melatonin levels in the serum of AD patients, and melatonin supplements are able to reverse AD pathology and memory deficits in many animal experiments and clinical trials. However, the underlying mechanism regarding how melatonin rescues the AD-like memory/synaptic disorder remains unknown. Here, we use the Morris water maze, step-down inhibitory avoidance task, in vivo long-term potentiation recording, and Golgi staining and report that intraperitoneal injection of melatonin (1 mg/kg/day) for 14 days in rats effectively reverses the memory and synaptic impairment in scopolamine-induced amnesia, a well-recognized dementia animal model. Using real-time polymerase chain reaction and western blotting experiments, we further determined that melatonin rescues the EPACs/miR-124/Egr1 signal pathway, which is important in learning and memory, as reported recently. Our studies provide a novel underlying epigenetic mechanism for melatonin to attenuate the synaptic disorder and could benefit drug discovery in neurodegenerative diseases.