Background: Melatonin has been shown with anticancer property and therapeutic potential for tumors. However, there lacks a systematic study on the molecular pathways of melatonin and its antitumor effects in gastrointestinal carcinomas. Methods: Using the gene expression profiles of four cancer cell lines from three types of gastrointestinal carcinomas before and after melatonin treatment, including gastric carcinoma (GC), colorectal carcinoma (CRC) and hepatocellular carcinoma (HCC), differentially expressed genes (DEGs) and biological pathways influenced by melatonin were identified. The qRT-PCR analyses were performed to validate the effects of melatonin on 5-FU resistance-related genes in CRC. Results: There were 17 pathways commonly altered by melatonin in the three cancer types, including FoxO signaling pathways enriched by the upregulated DEGs and cell cycle signaling pathways enriched by the downregulated DEGs, confirmed the dual role of melatonin to tumor growth, pro-apoptosis and anti-proliferation. DEGs upregulated in the three types of cancer tissues but reversely downregulated by melatonin were commonly enriched in RNA transport, spliceosome and cell cycle signaling pathways, which indicate that melatonin might exert antitumor effects through these pathways. Our results further showed that melatonin can downregulate the expression levels of 5-FU resistance-related genes, such as thymidylate synthase in GC and ATR, CHEK1, BAX and MYC in CRC. The qRT-PCR results demonstrated that melatonin enhanced the sensitivity of CRC 5-FU resistant cells by decreasing the expression of ATR. Conclusions: Melatonin exerts the effects of pro-apoptosis and anti-proliferation on gastrointestinal carcinomas, and might increase the sensitivity of 5-FU in GC and CRC patients.