Factors like sex, diet changes, hormone levels, and stressors disrupt animals' symbiotic bacterial communities. Maintaining healthy bacterial communities is particularly challenging for social species, as group membership, social relationships, microbial transfer, and social stressors influence their microbiotas. This study investigated the influence of sex and social dynamics on the gut microbiome and associated metabolites in the captive Yangtze finless porpoise (YFP), employing 16S rRNA gene sequencing and ultra-high-performance liquid chromatography with tandem mass spectrometry–based metabolomic analyses. The present study reveals that sex and social grouping, that is, male–male (MM), female–female (FF), and male–female (MF) groups, significantly influence the alpha and beta diversity in the captive YFP. The phylum Firmicutes were increased considerably in the FF social group, while Proteobacteria, Cyanobacteria, and Fusobacteriota were significantly increased in the MM group, while Desulfobacterota were risen considerably in the MF group. The genera Macrococcus, Clostridium_sensu_stricto_13, and Cetobacterium were considerably raised in the MM group, Paeniclostridium and Turicibacter were substantially raised in the FF group, while the genus Peptostreptococcaceae were substantially raised in the MF group. The current research also presented significant metabolite variations in the sex and social groups which significantly altered the metabolic pathways such as bile secretion, glycerophospholipid metabolism, protein digestion and absorption, citrate cycle, and carbohydrate digestion in the captive YFPs. Additionally, the research identified a significant correlation between the gut microbiome and fecal metabolome across different sex and social groups. In conclusion, this research highlights the connection between changes in fecal microbiota and host metabolism in captive YFP. It shows how sex and social group dynamics affect both metabolic and bacterial variations, offering valuable insights for improving health and social welfare management in captive YFPs.