Distinct motor programs can be coupled to refine the repertoire of behavior dynamics. However, mechanisms underlying such coupling are poorly understood. The defecation motor program (DMP) of C. elegans is composed of a succession of body contraction and expulsion steps, performed repeatedly with a period of 50-60 sec. We show that recurring patterns of directed locomotion are executed in tandem with, co-reset, and co-terminate with the DMP cycle. Calcium waves in the intestine and proton signaling were shown to regulate the DMP. We found that genetic manipulations affecting these calcium dynamics regulated the corresponding patterns of directed locomotion. Moreover, we observed the initiation of a recurring locomotion pattern 10 seconds prior to the posterior body contraction, suggesting that the synchronized motor program may initiate prior to the DMP. This study links two multi-step motor programs executed by C. elegans in synchrony, utilizing non-neuronal tissue to drive directed locomotion.