About one‐third of the workers have irregular working hours, subsequently putting them at risk of sleep disorders. It also has negative impacts on employee performance. Sleep disorders and executive performance have been attributed to melatonin dysregulation due to long‐term exposure to artificial light. This study investigates melatonin effects on sleep quality and cognitive performance in employees with sleep disorders following shift work. Seventy‐two patients with sleep disorders following shift work were equally assigned to melatonin (5 mg before sleep at night after shifts) or matched placebo groups in a randomized, parallel‐group, double‐blind, placebo‐controlled design. Patients were assessed using the short Pittsburgh Sleep Quality Index (shortPSQI), Occupational Cognitive Failure Questionnaire (OCFQ), and adverse events at baseline and weeks 1 and 4. Data from 65 patients were analyzed. Baseline characteristics were comparable between the groups (p values >0.05). The melatonin group showed a greater reduction in total shortPSQI score from baseline to the first (p value = 0.018) and fourth (p value = 0.001) weeks, as well as in total OCFQ score to the fourth week (p value <0.001). In addition, the time‐treatment interaction effects on total scores of shortPSQI (p value = 0.004) and OCFQ (p value <0.001) were significant. The only different adverse event between the two groups was fatigue, which was higher in the placebo group (p value = 0.042). Melatonin was safely and tolerably superior to placebo in treating patients with sleep disorders following shift work in the short term. Evidence also shows its effects on improving occupational cognitive performance in the medium term. The study protocol was registered and published prospectively in the Iranian registry of clinical trials (registration number: IRCT20090117001556N153).