Two experiments with growing pigs were conducted to determine the effects of dietary P and Ca levels, phytase supplementation, and ileal pectin infusion on changes in bacterial populations in the ileum and on ileal and fecal fermentation patterns. Growing pigs (BW 30.1 +/- 1.3 kg) were fitted with simple T-cannulas at the distal ileum and were fed a low-P corn-soybean meal control diet (3 g of P/kg), or the control diet supplemented with either 15 g of monocalcium phosphate (MCP)/kg (Exp. 1) or 1,000 phytase units of phytase/kg (Exp. 2). Daily infusion treatments consisted of either 60 g of pectin dissolved in 1.8 L of demineralized water or 1.8 L of demineralized water as a control infusion, infused via the ileal cannula. In each experiment, 8 barrows were assigned to 4 dietary treatments according to a double incomplete 4 x 2 Latin square design. The dietary treatments in Exp. 1 were the control diet with water infusion, the control diet with pectin infusion, the MCP diet with water infusion, or the MCP diet with pectin infusion. In Exp. 2, the pigs received the same control treatments as in Exp. 1 and the phytase diet in combination with water or pectin infusion. Gene copy numbers of total bacteria, Lactobacillus spp., Lactobacillus reuteri, Lactobacillus amylovorus/Lactobacillus sobrius, Lactobacillus mucosae, Enterococcus spp., Enterococcus faecium, Enterococcus faecalis, bifidobacteria, the Clostridium coccoides cluster, the Clostridium leptum cluster, the Bacteroides-Prevotella-Porphyrmonas group, and Enterobacteriaceae were determined by quantitative PCR in DNA extracts of ileal digesta. In Exp. 1, addition of MCP reduced ileal gene copy numbers of Enterococcus spp. (P = 0.048), E. faecium (P = 0.015), and the C. leptum cluster (P = 0.028), whereas pectin infusion enhanced (P = 0.008) ileal d-lactate concentration. In Exp. 2, supplemental phytase led to greater ileal gene copy numbers of the C. coccoides (P = 0.041) and C. leptum (P = 0.048) clusters and the Bacteroides-Prevotella-Porphyrmonas group (P = 0.033), whereas it reduced (P = 0.027) fecal n-butyrate concentration. Pectin infusion reduced (P = 0.005) ileal gene copy number of the C. leptum cluster. In conclusion, ileal bacterial populations and fermentation patterns are susceptible to changes in the intestinal availability of Ca and P as well as to the supply of pectin as a fermentable substrate. Greater intestinal Ca availability decreased the numbers of some gram-positive bacteria, whereas greater P availability in the small intestine caused by phytase activity enhanced the growth of strictly anaerobic bacteria.