Weaning is a critical period for piglets, in which unbalanced gut microbiota and/or pathogen colonisation can contribute to diseases that interfere with animal performance. Tannins are natural compounds that could be used as functional ingredients to improve gut health in pig farming thanks to their antibacterial, antioxidant, and antidiarrhoeal properties. In this study, a mixture of quebracho and chestnut tannins (1.25%) was evaluated for its efficacy in reducing the negative weaning effects on piglet growth. Microbiota composition was assessed by Illumina MiSeq 16S rRNA gene sequencing of DNA extracted from stools at the end of the trial. Sequence analysis revealed an increase in the genera Shuttleworthia, Pseudobutyrivibrio, Peptococcus, Anaerostipes, and Solobacterium in the tannin-supplemented group. Conversely, this dietary intervention reduced the abundance of the genera Syntrophococcus, Atopobium, Mitsuokella, Sharpea, and Prevotella. The populations of butyrate-producing bacteria were modulated by tannin, and higher butyrate concentrations in stools were detected in the tannin-fed pigs. Co-occurrence analysis revealed that the operational taxonomic units (OTUs) belonging to the families Veillonellaceae, Lachnospiraceae, and Coriobacteriaceae occupied the central part of the network in both the control and the tannin-fed animals. Instead, in the tannin group, the OTUs belonging to the families Acidaminococcaceae, Alcaligenaceae, and Spirochaetaceae characterised its network, whereas Family XIII Incertae Sedis occupied a more central position than in the control group. Conversely, the presence of Desulfovibrionaceae characterised the network of the control group, and this family was not present in the network of the tannin group. Moreover, the prediction of metabolic pathways revealed that the gut microbiome of the tannin group possessed an enhanced potential for carbohydrate transport and metabolism, as well as a lower abundance of pathways related to cell wall/membrane/envelope biogenesis and inorganic ion transport. In conclusion, the tested tannins seem to modulate the gut microbiota, favouring groups of butyrate-producing bacteria.