Sex is one of the important factors affecting gut microbiota. As key predators in agroforestry ecosystem, many spider species show dramatically different activity habits and nutritional requirements between females and males. However, how sex affects gut microbiota of spiders remains unclear. Here, we compared the composition and diversity of gut bacteria between female and male Pardosa astrigera based on bacterial 16S rRNA gene sequencing. Results showed that the richness of bacterial microbiota in female spiders was significantly lower than in male spiders (p < .05). Besides, β‐diversity showed a significant difference between female and male spiders (p = .0270). The relative abundance of Actinobacteriota and Rhodococcus (belongs to Actinobacteriota) was significantly higher in female than in male spiders (p < .05), whereas the relative abundance of Firmicutes and Acinetobacter (belongs to Proteobacteria) and Ruminococcus and Fusicatenibacter (all belong to Firmicutes) was significantly higher in male than in female spiders (p < .05). The results also showed that amino acid and lipid metabolisms were significantly higher in female than in male spiders (p < .05), whereas glycan biosynthesis and metabolism were significantly higher in male than in female spiders (p < .05). Our results imply that sexual variation is a crucial factor in shaping gut bacterial community in P. astrigera spiders, while the distinct differences of bacterial composition are mainly due to their different nutritional and energy requirements.