Caenorhabditis elegans explores its environment by interrupting its forward movement with occasional turns and reversals. Turns and reversals occur at stable frequencies but irregular intervals, producing probabilistic exploratory behaviors. Here we dissect the roles of individual sensory neurons, interneurons, and motor neurons in exploratory behaviors under different conditions. After animals are removed from bacterial food, they initiate a local search behavior consisting of reversals and deep omega-shaped turns triggered by AWC olfactory neurons, ASK gustatory neurons, and AIB interneurons. Over the following 30 min, the animals disperse as reversals and omega turns are suppressed by ASI gustatory neurons and AIY interneurons. Interneurons and motor neurons downstream of AIB and AIY encode specific aspects of reversal and turn frequency, amplitude, and directionality. SMD motor neurons help encode the steep amplitude of omega turns, RIV motor neurons specify the ventral bias of turns that follow a reversal, and SMB motor neurons set the amplitude of sinusoidal movement. Many of these sensory neurons, interneurons, and motor neurons are also implicated in chemotaxis and thermotaxis. Thus, this circuit may represent a common substrate for multiple navigation behaviors.