Carbon dioxide is produced as a by-product of cellular respiration by all aerobic organisms and thus serves for many animals as an important indicator of food, mates, and predators. However, whether free-living terrestrial nematodes such as Caenorhabditis elegans respond to CO2 was unclear. We have demonstrated that adult C. elegans display an acute avoidance response upon exposure to CO2 that is characterized by the cessation of forward movement and the rapid initiation of backward movement. This response is mediated by a cGMP signaling pathway that includes the cGMP-gated heteromeric channel TAX-2/TAX-4. CO2 avoidance is modulated by multiple signaling molecules, including the neuropeptide Y receptor NPR-1 and the calcineurin subunits TAX-6 and CNB-1. Nutritional status also modulates CO2 responsiveness via the insulin and TGFbeta signaling pathways. CO2 response is mediated by a neural circuit that includes the BAG neurons, a pair of sensory neurons of previously unknown function. TAX-2/TAX-4 function in the BAG neurons to mediate acute CO2 avoidance. Our results demonstrate that C. elegans senses and responds to CO2 using multiple signaling pathways and a neural network that includes the BAG neurons and that this response is modulated by the physiological state of the worm.