Background: Surgery is one of the stressors that cause physiological and psychological stress. Anxiety and pain and their complications are very important in anesthesiology and many researches have been done to decrease or eliminate them. This training was done to compare the effect of melatonin and gabapentin on pain and anxiety during lumbar surgery. Methods: This study was a double-blinded clinical trial conducted on 90 patients undergoing lumbar surgery with general anesthesia in Golestan Academic Hospital in 2017. Patients were randomly assigned into 3 groups: 30 patients received 6 mg melatonin, 30 patients received 600 mg gabapentin, and 30 patients were on placebo (control), 100 minutes preoperatively. All patients were given a fixed method of anesthesia. The pain intensity and patients' satisfaction from analgesia measured at 1, 2, 6, 12, and 24 h after surgery. The anxiety was measured 15 minutes before surgery and 1, 2, 6, 12, and 24 h after surgery.Results: In our study, there was a significant difference between mean Visual Analog Score between melatonin and gabapentin groups in comparison to placebo (P = 0.02). The intensity of anxiety among the groups was lower in melatonin and gabapentin groups in comparison to placebo (P = 0.01).Conclusions: The results show that pretreatment with melatonin or gabapentin decreases anxiety and pain in lumbar surgery.