Abstract Background Delirium is highly problematic in palliative care (PC). Preliminary data indicate a potential role for melatonin to prevent delirium, but no randomized controlled trials (RCTs) are reported in PC. Methods Patients aged ≥18 years, with advanced cancer, admitted to an inpatient Palliative Care Unit (PCU), having a Palliative Performance Scale rating ≥ 30%, and for whom consent was obtained, were included in the study. Patients with delirium on admission were excluded. The main study objectives were to assess the feasibility issues of conducting a double-blind RCT of exogenous melatonin to prevent delirium in PC: recruitment, retention, procedural acceptability, appropriateness of outcome measures, and preliminary efficacy and safety data. Study participants were randomized in a double-blind, parallel designed study to receive daily melatonin 3 mg or placebo orally at 21:00 over 28 days or less if incident delirium, death, discharge or withdrawal occurred earlier. Delirium was diagnosed using the Confusion Assessment Method. Efficacy endpoints in the melatonin and placebo groups were compared using time-to-event analysis: days from study entry to onset of incident delirium. Results Over 16 months, 60/616 (9.7%; 95% CI: 7.5–12.4%) screened subjects were enrolled. The respective melatonin (n = 30) vs placebo (n = 30) outcomes were: incident delirium in 11/30 (36.7%; 95%CI: 19.9–56.1%) vs 10/30 (33%; 95% CI: 17.3–52.8%); early discharge (6 vs 5); withdrawal (6 vs 3); death (0 vs 1); and 7 (23%) vs 11 (37%) reached the 28-day end point. The 25th percentile time-to-event were 9 and 18 days (log rank, χ2 = 0.62, p = 0.43) in melatonin and placebo groups, respectively. No serious trial medication-related adverse effects occurred and the core study procedures were acceptable. Compared to those who remained delirium-free during their study participation, those who developed delirium (n = 21) had poorer functional (p = 0.036) and cognitive performance (p = 0.013), and in particular, poorer attentional capacity (p = 0.003) at study entry. Conclusions A larger double-blind RCT is feasible, but both subject accrual and withdrawal rates signal a need for multisite collaboration. The apparent trend for shorter time to incident delirium in the melatonin group bodes for careful monitoring in a larger trial. Trial registration Registered on July 21st 2014 with ClinicalTrials.gov : NCT02200172 .