Objective. To investigate the influence of melatonin on behavioral and neurological function of rats with focal cerebral ischemia-reperfusion injury via the JNK/FoxO3a/Bim pathway. Methods. One hundred and twenty healthy male SD rats were randomized into the model group (Model: the middle cerebral artery occlusion (MCAO) model was constructed and received an equal volume of normal saline containing 5% DMSO), sham operation group (Sham: received no treatment except normal feeding), and low, medium, and high dose of melatonin group (L-MT, M-MT, and H-MT intraperitoneally injected 10, 20, and 40 mg/kg melatonin 30 min after IR, respectively), with 24 rats in each group. Following 24 h of reperfusion, the rats in each of the above groups were tested for neurological deficit symptoms and behavioral changes to screen the rats included in the study. HE and TUNEL stainings were performed to observe pathological changes. Levels of oxidative stress-related indexes, inflammatory factor-related indexes, nuclear factor-κB p65 (NF-κB p65), and interferon-γ (IFN-γ) in the rat brain were measured by ELISA. The JNK/FoxO3a/Bim pathway-related proteins as well as Bcl-2, Caspase-3, and Bax were examined using Western blot. Results. Detection of behavioral indicators showed that the MACO model was successfully constructed in rats. L-MT, M-MT, and L-MT groups presented reduced malondialdehyde (MDA), reactive oxygen species (ROS), tumor necrosis factor- (TNF-) α, interleukin- (IL-) 6, IL-1β, IFN-γ, NF-κB p65, and apoptosis compared with the Model group (
P
<
0.05
), and the improvement degree was better in the M-MT group versus the L-HT group. Bcl-2 protein expression in the brain tissue of L-MT, M-MT, and H-MT groups increased significantly, while Bax, Caspase-3, p-JNK, p-FoxO3a, and Bim protein expression declined markedly, versus the Model group (
P
<
0.05
). The changes of indexes were greater in the M-MT group compared with that in the L-MT group. No significant difference was observed in all the above indexes between the M-MT group and the H-MT group (
P
>
0.05
). Conclusions. In the MACO rat model, melatonin can effectively reduce Bax and Caspase-3 levels by modulating the JNK/FoxO3a/Bim pathway, inhibit neuronal apoptosis, and alleviate neurological deficits by reducing the release of proinflammatory mediators, with anti-inflammatory and antioxidant effects. In addition, 20 mg/kg is the optimal melatonin concentration.