Resistant starch can alter the intestinal nutrient availability and bulk of digesta, thereby modulating the substrate available for microbial metabolic activity along the gastrointestinal tract. This study elucidated the effect of transglycosylated starch (TGS) on the retention of digesta in the upper digestive tract, ileal flow and hindgut disappearance of nutrients, and subsequent bacterial profiles in pigs. Fourteen ileal-cannulated growing pigs were fed either the TGS or control (CON) diet in a complete crossover design. Each period consisted of a 10-d adaptation to the diets, followed by 3-d collection of faeces and ileal digesta. Consumption of TGS decreased the retention of digesta in the stomach and small intestine, and increased ileal DM, starch, Ca and P flow, leading to enhanced starch fermentation in the hindgut compared with CON-fed pigs. TGS increased ileal and faecal total SCFA, especially ileal and faecal acetate and faecal butyrate. Gastric retention time positively correlated to Klebsiella, which benefitted together with Selenomonas, Lactobacillus, Mitsuokella and Coriobacteriaceae from TGS feeding and ileal starch flow. Similar relationships existed in faeces with Coriobacteriaceae, Veillonellaceae and Megasphaera benefitting most, either directly or indirectly via cross-feeding, from TGS residuals in faeces. TGS, in turn, depressed genera within Ruminococcaceae, Clostridiales and Christensenellaceae compared with the CON diet. The present results demonstrated distinct ileal and faecal bacterial community and metabolite profiles in CON- and TGS-fed pigs, which were modulated by the type of starch, intestinal substrate flow and retention of digesta in the upper digestive tract.