Diet has major effects on the intestinal microbiota, but the exact mechanisms that alter complex microbial communities have been difficult to elucidate. In addition to the direct influence that diet exerts on microbes, changes in microbiota composition and function can alter host functions such as gastrointestinal (GI) transit time, which in turn can further affect the microbiota. We investigated the relationships among diet, GI motility, and the intestinal microbiota using mice that are germ-free (GF) or humanized (ex-GF mice colonized with human fecal microbiota). Analysis of gut motility revealed that humanized mice fed a standard polysaccharide-rich diet had faster GI transit and increased colonic contractility compared with GF mice. Humanized mice with faster transit due to administration of polyethylene glycol or a nonfermentable cellulose-based diet had similar changes in gut microbiota composition, indicating that diet can modify GI transit, which then affects the composition of the microbial community. However, altered transit in mice fed a diet of fermentable fructooligosaccharide indicates that diet can change gut microbial function, which can affect GI transit. Based on studies in humanized mice, diet can affect GI transit through microbiota-dependent or microbiota-independent pathways, depending on the type of dietary change. The effect of the microbiota on transit largely depends on the amount and type (fermentable vs nonfermentable) of polysaccharides present in the diet. These results have implications for disorders that affect GI transit and gut microbial communities, including irritable bowel syndrome and inflammatory bowel disease. Copyright © 2013 AGA Institute. Published by Elsevier Inc. All rights reserved.