The vagus nerve plays a role in the cross talk between the brain and gut microbiota, which could be involved in depression. The subdiaphragmatic vagus nerve serves as a major modulatory pathway between the brain and gut microbiota. Here, we investigated the effects of subdiaphragmatic vagotomy (SDV) on the depression-like phenotype and the abnormal composition of gut microbiota in mice after lipopolysaccharide (LPS) administration. LPS caused a depression-like phenotype, inflammation, increase in spleen weight, and downregulation of synaptic proteins in the medial prefrontal cortex (mPFC) in the sham-operated mice. In contrast, LPS did not produce a depression-like phenotype and downregulated synaptic proteins in the mPFC after SDV. The spleen weight and plasma levels of proinflammatory cytokines in the SDV + LPS group were lower than those of the sham + LPS group. Interestingly, there were positive correlations between the plasma levels of pro-inflammatory cytokines and spleen weight, suggesting a relationship between inflammatory events and spleen weight. Furthermore, LPS led to significant alterations in gut microbiota diversity in sham-operated mice, but not SDV-operated mice. In an unweighted UniFrac PCoA, the dots representing the sham + LPS group were located far away from the dots representing the other three groups. Our results suggest that LPS produces a depression-like phenotype, increases spleen weight, triggers inflammation, downregulates synaptic proteins in the mPFC, and leads to abnormal composition of gut microbiota via the subdiaphragmatic vagus nerve. It is likely that the vagus nerve plays a crucial role in the brain-gut-microbiota axis.