Tissue-tissue communications are integral to organismal aging, orchestrating a body-wide aging process. The brain plays a key role in this process by detecting and processing signals from the environment and then communicating them to distal tissues such as the gut to regulate longevity. How this is achieved, however, is poorly understood. Here, using Caenorhabditis elegans as a model, we identified two distinct neuroendocrine signaling circuits by which the worm nervous system senses cool and warm environmental temperatures through cool- and warm-sensitive neurons and then signals the gut to extend and shorten life span, respectively. The prolongevity "cool" circuit uses the small neurotransmitters glutamate and serotonin, whereas the anti-longevity "warm" circuit is mediated by insulin-like neuropeptides. Both types of neuroendocrine signals converge on the gut through their cognate receptors to differentially regulate the transcription factor DAF-16/FOXO, leading to opposing outcomes in longevity. Our study illustrates how the brain detects and processes environmental signals to bidirectionally regulate longevity by signaling the gut.