Rhythmic movements are ubiquitous in animal locomotion, feeding, and circulatory systems. In some systems, the muscle itself generates rhythmic contractions. In others, rhythms are generated by the nervous system or by interactions between the nervous system and muscles. In the nematode Caenorhabditis elegans, feeding occurs via rhythmic contractions (pumping) of the pharynx, a neuromuscular feeding organ. Here, we use pharmacology, optogenetics, genetics, and electrophysiology to investigate the roles of the nervous system and muscle in generating pharyngeal pumping. Hyperpolarization of the nervous system using a histamine-gated chloride channel abolishes pumping, and optogenetic stimulation of pharyngeal muscle in these animals causes abnormal contractions, demonstrating that normal pumping requires nervous system function. In mutants that pump slowly due to defective nervous system function, tonic muscle stimulation causes rapid pumping, suggesting tonic neurotransmitter release may regulate pumping. However, tonic cholinergic motor neuron stimulation, but not tonic muscle stimulation, triggers pumps that electrophysiologically resemble typical rapid pumps. This suggests that pharyngeal cholinergic motor neurons are normally rhythmically, and not tonically active. These results demonstrate that the pharynx generates a myogenic rhythm in the presence of tonically released acetylcholine, and suggest that the pharyngeal nervous system entrains contraction rate and timing through phasic neurotransmitter release.