Cholestasis is a pathological state characterized by the dysfunction of bile acid flow, which could lead to liver fibrosis, cirrhosis, and even liver failure, but its therapeutic agents are limited. The aim of this study was to investigate the therapeutic potential and underlying mechanism of melatonin on cholestatic liver injury. C57BL/6 J mice were fed with 0.05 % 3,5-diethoxycarbonyl-1,4-dihydro-2,4,6-collidine (DDC) diet to induce cholestatic liver injury, with or without daily intraperitoneal injection of 20 mg/kg melatonin. The supplementation of melatonin alleviated cholestatic liver injury through improving liver histopathology and abnormal serum indicators reflecting liver function. Meanwhile, melatonin treatment inhibited the hepatic inflammatory infiltration and release of pro-inflammatory cytokines. Moreover, liver fibrosis caused by cholestasis was mitigated by melatonin via reducing collagen deposition and pro-fibrogenic factors. Furthermore, the gut microbiota dysbiosis and impaired intestinal barrier induced by DDC were mitigated after melatonin treatment. Notably, melatonin activated the cholangiocyte nuclear factor erythroid 2-related factor 2 (NRF2) / heme oxygenase-1 (HO-1) signalling pathway through melatonin receptor 1 A (MTNR1A) to protect the liver from oxidative stress damage. In conclusion, melatonin is a potential therapeutic agent for cholestatic liver injury, possibly acting by modulating gut microbiota and activating the NRF2/HO1 pathway.