Background: Gastric cancer (GC) is the main malignancy affecting a large population worldwide. Lack of effective enough treatment is one of the leading factors contributing to the high mortality rate. Melatonin, a naturally occurring compound, has been proven to exert cytotoxic and antiproliferative effects on human gastric cancers. Nevertheless, the mechanisms of anti-gastric cancer of melatonin remain elucidated. It is believed that endoplasmic reticulum (ER) stress and its resultant unfolded protein response (UPR) are connected to the survival, progression, and chemoresistance of various tumor cells via multiple cellular procedures, such as autophagy. In this study, the effects of melatonin on human gastric cancer cell lines AGS and SGC-7901 was assessed to reveal the interaction between melatonin, endoplasmic reticulum stress, and autophagy in gastric cancer. Methods: CCK-8, the wound healing analysis, colony formation assay, immunofluorescence analysis, Western blotting, flow cytometry, and animal models were used in the current study. Results: The data demonstrated that melatonin could inhibit GC growth, proliferation, and invasion both in vivo and in vitro. Apoptosis and autophagy induced in a concentrationdependent manner is response to melatonin-induced ER stress. Melatonin induced the expression of apoptotic and autophagy-related proteins, which was markedly attenuated by the ER stress inhibitor 4-PBA and autophagy inhibitor 3-MA. In addition, we used the specific IRE1 inhibitor STF 083010, finding that inhibiting IRE1 could considerably relieve ER stress-induced autophagy activity, as revealed by the reduction of LC3-II and Beclin-1. Conclusion: This study confirmed that melatonin-induced inhibition of GC cell proliferation is mediated by the activation of the IRE/JNK/Beclin1 signaling.