The functional relationship between cardioacceleratory peptide 2 (CAP2) and hindgut activity during wandering behaviour was investigated in fifth-instar larvae of the tobacco hawkmoth Manduca sexta. Inspection of the alimentary canal on the day prior to wandering showed that the gut, in preparation for metamorphosis, was voided of all contents by 18:00 h. Associated with this event, which we refer to as 'gut emptying', was an increase in the frequency of hindgut contractions measured in vivo. No change in heart activity was seen during this developmental period. Measurements of the amount of CAP2 in the central nervous system (CNS) of fifth-instar caterpillars revealed that CAP2 storage levels declined sharply on the day of gut emptying. The drop in CNS levels of CAP2 at gut emptying was temporally correlated with the appearance of CAP2 in the haemolymph. CAP2, when applied at physiological concentrations to an in vitro larval hindgut bioassay, caused changes in several parameters, including contraction frequency and amplitude, and basal tension. In vivo administration of CAP2 elicited hindgut responses that were qualitatively and quantitatively similar to those seen in vitro. Developmental studies on changes in CAP2 responsiveness during the last larval instar demonstrated that the hindgut is maximally sensitive to CAP2 on the day of gut emptying. Direct evidence in support of a role for CAP2 in fifth-instar larvae was provided by experiments in which the increase in gut activity in vivo seen at gut emptying was significantly reduced by injections of an anti-CAP antibody. Based on data from cobalt backfills and anti-CAP immunohistochemical staining, we propose that CAP2 exerts its effect on the larval hindgut at wandering via a local release from CAP-containing neurones in the terminal ganglion that project directly to the hindgut.