The gut microbiota has emerged as an environmental factor that modulates the development of the central nervous system (CNS) and the enteric nervous system (ENS). Before obtaining its own microbiota, eutherian foetuses are exposed to products and metabolites from the maternal microbiota. At birth, the infants are colonised by microorganisms. The microbial composition in early life is strongly influenced by the mode of delivery, the feeding method, the use of antibiotics and the maternal microbial composition. Microbial products and microbially produced metabolites act as signalling molecules that have direct or indirect effects on the CNS and the ENS. An increasing number of studies show that the gut microbiota can modulate important processes during development, including neurogenesis, myelination, glial cell function, synaptic pruning and blood‐brain barrier permeability. Furthermore, numerous studies indicate that there is a developmental window early in life during which the gut microbial composition is crucial and perturbation of the gut microbiota during this period causes long‐lasting effects on the development of the CNS and the ENS. However, other functions are readily modulated in adult animals, including microglia activation and neuroinflammation. Several neurobehavioural, neurodegenerative, mental and metabolic disorders, including Parkinson disease, autism spectrum disorder, schizophrenia, Alzheimer's disease, depression and obesity, have been linked to the gut microbiota. This review focuses on the role of the microorganisms in the development and function of the CNS and the ENS, as well as their potential role in pathogenesis.