Simple Summary Recent studies have shown a correlation between piglet diarrhea and the gut microbiota. However, the precise mechanism by which intestinal microorganisms and their metabolites influence diarrhea in weaned piglets remains unclear. This study explored differences in the gut microbiota and associated metabolites between healthy and diarrheic-weaned piglets using macrogenomic and metabolomic analyses. We identified microorganisms that differed markedly between the two groups. We noticed that the number and abundance of Bacteroidaceae bacterium were strongly negatively correlated with diarrhea in weaned piglets, whereas Caudoviricetes exhibited a strong positive correlation. Our screening for markedly different metabolites such as carnosine, pantothenic acid, pyridoxal, methylimidazoleacetic acid, indole-3-acetaldehyde and 5-hydroxyindoleacetic acid, along with the identification of metabolite-related metabolic pathways like tryptophan and vitamin B6 metabolism, identified important pathways associated with gut microbiota dysbiosis caused by post-weaning diarrhea in piglets. Conjoint analysis revealed that a substantial increase in the number and abundance of Caudoviricetes, coupled with a decrease in the number and abundance of Bacteroidaceae bacterium could potentially serve as microbial markers of post-weaning diarrhea.Abstract Recent studies have shown a correlation between piglet diarrhea and the gut microbiota. However, the precise mechanism by which intestinal microorganisms and their metabolites influence diarrhea in weaned piglets remains unclear. This study explored differences in the gut microbiota and associated metabolites between healthy and diarrheic-weaned piglets using macrogenomic and metabolomic analyses. The histomorphological results showed that diarrheic piglets had shorter jejunal and ileal villi, some of which were shed, compared to healthy piglets. Substantial differences in gut microbial diversity and metabolites were also observed, with Bacteroidaceae bacterium and Caudoviricetes being the main differential organisms that were strongly correlated with host status. Microbial functions, mainly the metabolism of carbohydrates, glycans, lipids, and amino acids, as well as related enzyme activities, were substantially different. The major differential metabolites were carnosine, pantothenic acid (vitamin B5), pyridoxal, methylimidazoleacetic acid, indole-3-acetaldehyde, and 5-hydroxyindoleacetic acid. These metabolites were enriched in beta-alanine, histidine, tryptophan, and vitamin B6 metabolism, and in the pantothenate and CoA biosynthesis pathways. Combined macrogenomic and metabolomic analyses revealed that carnosine, vitamin B5, and pyridoxal were negatively correlated with Caudoviricetes; methylimidazoleacetic acid, indole-3-acetaldehyde, and 5-hydroxyindoleacetic acid were positively correlated with Caudoviricetes. Whereas carnosine and vitamin B5 were positively correlated with Bacteroidaceae bacterium, 5-hydroxyindoleacetic acid was negatively correlated. The decreased abundance of Bacteroidaceae bacterium and the increased abundance of Caudoviricetes and related metabolites likely contribute to post-weaning diarrhea in piglets. Therefore, the abundance of Bacteroidaceae bacterium and Caudoviricetes can likely serve as potential markers for identifying and preventing diarrhea in post-weaning piglets.