C. elegans pharyngeal behavior consists of two distinct types of muscle contractions, termed pumping and peristalsis. Pumping ingests and concentrates bacteria in the anterior pharyngeal lumen, and it is occasionally followed by a transient peristaltic contraction that carries ingested bacteria through the posterior pharyngeal isthmus. These behaviors are controlled by a small pharyngeal nervous system consisting of 20 neurons that is almost completely independent of the extra-pharyngeal nervous system. The cholinergic motor neuron M4 controls peristalsis via synapses with the posterior isthmus muscles. Here we show that the NK-2 family homeobox gene ceh-28 is expressed in M4, where it regulates synapse assembly and peristalsis. ceh-28 mutants exhibit frequent and prolonged peristalses, and treatment with agonists or antagonists of muscarinic acetylcholine receptors can phenocopy or suppress ceh-28 mutant defects, respectively. Synapses in ceh-28 mutant M4 cells are irregularly spaced and sized, and they are abnormally located along the full length of the isthmus. We suggest that CEH-28 inhibits synaptogenesis, and that ceh-28 mutant behavioral defects result from excessive or ectopic stimulation of muscarinic acetylcholine receptors in the isthmus muscles.