The gut microbiota is directly influenced by dietary components, and it plays critical roles in chronic diseases. Excessive consumption of trans-fatty acids (TFA) is associated with obesity induced by alterations in gut microbiota, but the links between obesity and gut microbiota remain unclear. Therefore, studies examining the impact of TFA on intestinal microflora are essential. In our study, we performed 16S ribosomal RNA gene sequencing on faecal samples from Sprague–Dawley rats fed a basal diet (control (CON) group), high-fat (HF) diet (diet-induced obesity (DIO) group) or TFA diets (1 % TFA group and 8 % TFA group) for 8 weeks to investigate the effects of TFA/HF diets on obesity and gut microbiota composition. We found that the TFA/HF diets significantly induced obesity and changes in blood and brain physiological parameters of the rats. The relative abundance of the phyla Firmicutes and Bacteroidetes was inversely altered in the three test groups compared with the CON group. Proteobacteria increased slightly in the DIO, 1 % TFA and 8 % TFA groups. The genus Bacteroides increased in the DIO and 1 % TFA groups, but Muribaculaceae decreased in all experimental groups compared with the CON group. Moreover, significant differences were observed among clusters of orthologous group functional categories of the four dietary groups. Our observations suggested that the TFA/HF diets induced obesity and dysfunction of gut microbiota. Gut dysbiosis might mediate the obesity effects of TFA/HF diets.