A three-part motor program mediates a defecation every 45 sec in well- fed wild-type Caenorhabditis elegans. Individual worms maintain this 45 sec rhythm with an SD of about 3 sec. We present evidence that the defecation cycle is controlled by an endogenous clock, most likely a neuronal pattern generator. The phase of the behavioral rhythm can be reset like pattern generators in other animals. The rhythm was reset by stimulating a well-characterized neuronal circuit mediating response to light touch. Also, animals that spontaneously stopped feeding interrupted their defecation rhythms. When they resumed feeding these animals reactivated the motor program in phase with the previously established rhythm, indicating that an endogenous clock continues to run even when the behavior is not expressed. Control of the defecation rhythm is independent of expression of the motor program. Most previously isolated mutations that affect the motor program (Thomas, 1990) do not alter the rhythm of the behavior; the motor steps themselves are defective but not the timing of their activation. Laser kills of identified motor neurons that affect particular parts of the motor program also did not change the defecation rhythm. Another sensory stimulus, food, strongly modulates defecation behavior: animals away from food rarely activated the motor program, and food dilution resulted in a graded lengthening of the cycle period. To elucidate further the relationship between feeding and defecation rhythms we studied a mutation, dec-8(sa200), that caused worms to continue to activate the motor program in the absence of food. The mutant did not require the presence of food to activate the motor program, although food made the rhythm more precise. In the presence of food, dec- 8(sa200) animals exhibited tandem activations of the defecation motor program; the principal activation was followed by a more variable second activation. Further experiments suggested that the tandem activations of the motor program are not due to the activity of multiple oscillators.