The interaction between host and external environment mainly occurs in the gastrointestinal tract, where the mucosal barrier has a critical role in many physiologic functions ranging from digestion, absorption, and metabolism. This barrier allows the passage and absorption of nutrients, but at the same time, it must regulate the contact between luminal antigens and the immune system, confining undesirable products to the lumen. Diet is an important regulator of the mucosal barrier, and the cross-talk among dietary factors, the immune system, and microbiota is crucial for the modulation of intestinal permeability and for the maintenance of gastrointestinal tract (GI) homeostasis. In the present review, we will discuss the role of a number of dietary nutrients that have been proposed as regulators of inflammation and epithelial barrier function. We will also consider the metabolic function of the microbiota, which is capable of elaborating the diverse nutrients and synthesizing products of great interest. Better knowledge of the influence of dietary nutrients on inflammation and barrier function can be important for the future development of new therapeutic approaches for patients with mucosal barrier dysfunction, a critical factor in the pathogenesis of many GI and non-GI diseases.