Background/Aims: Stress is closely related to the deterioration of digestive disease. Melatonin has potent anti-inflammatory properties. The objective of this study was to determine the effect of water stress (WS) and sleep deprivation (SD) on intestinal microbiota and roles of melatonin in stressful condition. Methods: We used C57BL/6 mice and specially designed water bath for stress and SD for 10 days. We measured melatonin concentrations in serum, feces, and colon tissues by high-performance liquid chromatography. Genomic DNA was extracted from feces and amplified using primers targeting V3 to V4 regions of bacterial 16S ribosomal RNA genes. Results: Compared to the control, melatonin concentration was lower in the WS and SD. Fecal concentration was 0.132 pg/mL in control, 0.062 pg/mL in WS, and 0.068 pg/mL in SD. In colon tissue, it was 0.45 pg/mL in control, 0.007 pg/mL in WS, and 0.03 pg/mL in SD. After melatonin treatment, melatonin concentrations in feces and colon tissue were recovered to the level of control. Metagenomic analysis of microbiota showed abundance in colitogenic microbiota in WS and SD. Melatonin injection attenuated this harmful effect. WS and SD showed decreased <i>Lactobacillales</i> and increased <i>Erysipelotrichales</i> and <i>Enterobacteriales</i>. Melatonin treatment increased <i>Akkermansia muciniphila</i> and <i>Lactobacillus</i> and decreased <i>Bacteroides massiliensis</i> and <i>Erysipelotrichaceae</i>. Conclusions: This study showed that stress and SD could affect intestinal dysbiosis and increase colitogenic microbiota, which could contribute to the aggravating digestive disease. Melatonin concentrations in feces and colon tissue decreased under WS and SD. Melatonin treatment brought recovery of melatonin concentration in colon tissue and modulating dysbiosis of intestinal microbiota.