Although melatonin is mainly produced by the pineal gland, an increasing number of extra-pineal sites of melatonin synthesis have been described. We previously demonstrated the existence of bidirectional communication between the pineal gland and the immune system that drives a switch in melatonin production from the pineal gland to peripheral organs during the mounting of an innate immune response. In the present study, we show that acute neuroinflammation induced by lipopolysaccharide (LPS) injected directly into the lateral ventricles of adult rats reduces the nocturnal peak of melatonin in the plasma and induces its synthesis in the cerebellum, though not in the cortex or hippocampus. This increase in cerebellar melatonin content requires the activation of nuclear factor kappa B (NF-κB), which positively regulates the expression of the key enzyme for melatonin synthesis, arylalkylamine N-acetyltransferase (AA-NAT). Interestingly, LPS treatment led to neuronal death in the hippocampus and cortex, but not in the cerebellum. This privileged protection of cerebellar cells was abrogated when G-protein-coupled melatonin receptors were blocked by the melatonin antagonist luzindole, suggesting that the local production of melatonin protects cerebellar neurons from LPS toxicity. This is the first demonstration of a switch between pineal and extra-pineal melatonin production in the central nervous system following a neuroinflammatory response. These results have direct implications concerning the differential susceptibility of specific brain areas to neuronal death.Electronic supplementary materialThe online version of this article (doi:10.1007/s00429-013-0686-4) contains supplementary material, which is available to authorized users.