The relationships between depression and gut microbiota, particularly those involving the immune system, have become a major focus of recent research. Here, we analyzed changes in gut microbiota and their sulfur metabolites in the feces of a depression rat model using the modified 14-day social defeat stress (SDS) paradigm. Our results showed that SDS increased fecal Lactobacillus reuteri in correlation with ergothioneine levels at around day 11, which continued for at least 1 month following SDS administration. In vitro study further revealed that L. reuteri is capable of producing ergothioneine. Although the known anti-inflammatory and anti-oxidative actions of ergothioneine suggested that the increased fecal ergothioneine levels may be related to intestinal anti-inflammatory defense mechanisms, no change was observed in the plasma ergothioneine levels during the same observation period, indicating that the defense mechanisms may not be sufficiently reflected in the body. As ergothioneine is a natural ingredient that is absorbed mainly from the upper gastrointestinal tract, we hypothesized that oral ergothioneine may exert antidepressant effects. As expected, oral administration of ergothioneine prior to and during the SDS paradigm had a preventative effect on SDS-induced depressive behaviors, such as social avoidance and depression-like sleep abnormalities, particularly those of rapid eye movement sleep. These findings indicate that ergothioneine, a metabolite of L. reuteri, may be a common substance in the microbiota-gut-brain axis that prevents stress-induced sleep disturbances, especially those associated with depression.