Lifespan of C. elegans is affected by the nervous system; however, the underlying neural integration still remains unclear. In this work, we targeted an antagonistic neural system consisting of low-oxygen sensing BAG neurons and high-oxygen sensing URX neurons. While ablation of BAG neurons increases lifespan of C. elegans, ablation of URX neurons decreases lifespan. Genetic analysis revealed that BAG and URX neurons counterbalance each other via different guanylate cyclases (GCYs) to control lifespan balance. Lifespan-modulating effects of GCYs in these neurons are independent of the actions from insulin/IGF-1 signalling, germline signalling, sensory perception, or dietary restriction. Given the known gas-sensing property of these neurons, we profiled that lifespan of C. elegans is promoted under moderately low oxygen (4-12%) or moderately high carbon dioxide (5%) but inhibited under high-level oxygen (40%); however, these pro-longevity and anti-longevity effects are counteracted, respectively, by BAG and URX neurons via different GCYs. In conclusion, BAG and URX neurons work as a neural-regulatory system to counterbalance each other via different GCYs to control lifespan homeostasis.