Communication between the brain and gut is not one-way, but a bidirectional highway whereby reciprocal signals between the two organ systems are exchanged to coordinate function. The messengers of this complex dialogue include neural, metabolic, endocrine and immune mediators responsive to diverse environmental cues, including nutrients and components of the intestinal microbiota (microbiota-gut-brain axis). We are now starting to understand how perturbation of these systems affects transition between health and disease. The pathological repercussions of disordered gut-brain dialogue are probably especially pertinent in functional gastrointestinal diseases, including IBS and functional dyspepsia. New insights into these pathways might lead to novel treatment strategies in these common gastrointestinal diseases. In this Review, we consider the role of the immune system as the gatekeeper and master regulator of brain-gut and gut-brain communications. Although adaptive immunity (T cells in particular) participates in this process, there is an emerging role for cells of the innate immune compartment (including innate lymphoid cells and cells of the mononuclear phagocyte system). We will also consider how these key immune cells interact with the specific components of the enteric and central nervous systems, and rapidly respond to environmental variables, including the microbiota, to alter gut homeostasis.