Background: Patients with major depression are accompanied by intestinal flora flocculation; however, the relationship between the composition of gut microbiota in pregnancy and postpartum depression (PPD) has not been established. In this study we determined the effect of the gut microbiota in pregnant women during 32-39 weeks of gestation on PPD.Methods: Participants (n = 74) were enrolled between 2016–2017 from the Guangzhou Women and Children’s Medical Centre (GWCMC). Stool samples were collected during 32-39 weeks of gestation, and the relative abundance of fecal microbiota was characterized by 16S rRNA sequencing. The parturients completed the mainland Chinese version of the Edinburgh Postnatal Depression Scale (EPDS) 42 days postpartum to detect PPD. The linear discriminant analysis (LDA) effect size (LEfSe) method was used to identify bacterial population differences between the PPD and control groups.Results: The top three bacteria phyla in the PPD and control groups were Firmicutes, Bacteroidetes, and Actinobacteria. Compared with healthy pregnant women, the alpha diversity index of the PPD group was lower. Beta diversity analysis was performed by PCoA showing that no significant differences in bacterial community structures between the two groups (R2 = 0.013, P = 0.549). The composition of gut microbiota during 32-39 weeks of gestation of the two groups was different. At the genera level, Acinetobacter, Plesiomonas, Enterococcus, Olsenella, Alloscardovia, and Anaerotruncus were increased in the PPD group, while Lactococcus, Adlercreutzia, Clostridium, Coprococcus, and unclassified-Clostridiales were decreased. At the species level, hypermegale, uli, casseliflavus, and hathewayi were increased in the PPD group, and celatum was increased in the control group.Conclusions: During 32-39 weeks of gestation, a reduction in diversity of gut microbiota and anti-inflammatory bacteria, and an increase in opportunistic pathogenic bacteria are more likely to cause PPD.