Light pollution is a potential risk for intestinal health in humans and animals. The gut microbiota is associated with the development of intestinal inflammation induced by extended exposure to light, but the underlying mechanism is not yet clear. The results of this study showed that extended exposure to light (18L:6D) damaged intestinal morphology, downregulated the expression of tight junction proteins, and upregulated the expression of the NLRP3 inflammasome and the concentration of pro-inflammatory cytokines. In addition, extended exposure to light significantly decreased the abundance of Lactobacillus, Butyricicoccus, and Sellimonas and increased the abundance of Bifidobacterium, unclassified Oscillospirales, Family_XIII_UCG-001, norank_f__norank_o__Clostridia_vadinBB60_group, and Defluviitaleaceae_UCG-01. Spearman correlation analysis indicated that gut microbiota dysbiosis positively correlated with the activation of the NLRP3 inflammasome. The above results indicated that extended exposure to light induced intestinal injury by NLRP3 inflammasome activation and gut microbiota dysbiosis. Antibiotic depletion intestinal microbiota treatment and cecal microbiota transplantation (CMT) from the 12L:12D group to 18L:6D group indicated that the gut microbiota alleviated intestinal inflammatory injury induced by extended exposure to light via inhibiting the activation of the NLRP3 inflammasome. In conclusion, our findings indicated that the gut microbiota can alleviate intestinal inflammation induced by extended exposure to light via inhibiting the activation of the NLRP3 inflammasome.