This investigation was designed to determine the effect of melatonin supplementation on mental health parameters, metabolic and genetic profiles in patients under methadone maintenance treatment (MMT). This randomized, double-blind, placebo-controlled, clinical trial was conducted among 54 patients under MMT. Participants were randomly allocated to receive either 10 mg melatonin (2 melatonin capsules, 5 mg each) (n = 26) or placebo (n = 28) once a day, 1 hour before bedtime for 12 weeks. Melatonin supplementation significantly decreased Pittsburgh Sleep Quality Index (β -4.08; 95 percent CI, -5.51, -2.65; P < 0.001), Beck Depression Inventory index (β -5.46; 95% CI, -8.92, -2.00; P = 0.003) and Beck Anxiety Inventory index (β -3.87; 95% CI, -5.96, -1.77; P = 0.001) and significantly increased International Index of Erectile Functions (β 5.59; 95% CI, 1.76, 9.42; P = 0.005) compared with the placebo. Subjects who received melatonin supplements had significantly lower serum insulin levels (β -2.53; 95% CI, -4.48, -0.59; P = 0.01), homeostasis model of assessment-insulin resistance (β -0.56; 95% CI, -1.03, -0.09; P = 0.01) and higher quantitative insulin sensitivity check index (β 0.01; 95% CI, 0.004, 0.02; P = 0.009) and HDL-cholesterol levels (β 3.71; 95% CI, 1.77, 5.64; P = 0.002) compared to placebo. Additionally, melatonin intake resulted in a significant reduction in serum high sensitivity C-reactive protein (β -0.15; 95% CI, -0.27, -0.02; P = 0.02), malondialdehyde (β -0.31; 95% CI, -0.57, -0.05; P = 0.02) and protein carbonyl (β -0.06; 95% CI, -0.09, -0.04; P < 0.001). This trial indicated that taking melatonin supplements for 12 weeks by patients under MMT had beneficial effects on their mental health metabolic profiles.