Casein glycomacropeptide (CGMP), a glycoprotein originating during cheese manufacture, has shown promising effects by promoting the growth of some beneficial bacteria in vitro, although its activity has not been well explored. The present study was designed to evaluate the effects of CGMP against enterotoxigenic Escherichia coli (ETEC) K88 in vitro (Trial 1) and in vivo (Trial 2). In Trial 1, increasing concentrations of CGMP (0, 0·5, 1·5 or 2·5 mg/ml) were tested regarding its ability to block the attachment of ETEC K88 to ileal mucosa tissues obtained from piglets. Increasing the concentration of CGMP resulted in a gradual decrease in ETEC K88 attachment to the epithelial surface. In Trial 2, seventy-two piglets were distributed in a 2 × 2 factorial combination including or omitting CGMP in the diet (control diet v. CGMP) and challenged or not with ETEC K88 (yes v. no). Inclusion of CGMP increased crude protein, ammonia and isoacid concentrations in colon digesta. CGMP also increased lactobacilli numbers in ileum and colon digesta, and reduced enterobacteria counts in mucosa scrapings and the percentage of villi with E. coli adherence measured by fluorescence in situ hybridisation. The inclusion of CGMP in the diets of challenged animals also prevented the increase of enterobacteria in ileal digesta. We can conclude that CGMP may improve gut health by diminishing the adhesion of ETEC K88 to the intestinal mucosa, by increasing the lactobacilli population in the intestine and by reducing the overgrowth of enterobacteria in the digestive tract of piglets after an ETEC K88 challenge.