More than a decade ago it was proposed that the collective migration of African trypanosomes on semi-solid surfaces could be explained by a combination of migration factors and repellents released by the parasites, but the identity of these molecules was unknown. Here we show that procyclic (insect midgut) forms acidify their environment as a consequence of glucose metabolism, generating pH gradients by diffusion. Early and late procyclic forms exhibit self-organising properties on surfaces. Both forms are attracted to alkali, but while early procyclic forms are repelled by acid and migrate outwards, late procyclic forms remain at the inoculation site. pH taxis relies on cyclic AMP signalling. Acid sensing requires a flagellar adenylate cyclase, ACP5, and a cyclic AMP response protein, CARP3, that interacts with ACP5. Deletion of the flagellar phosphodiesterase PDEB1 abolishes pH taxis completely. Trypanosomes can also respond to exogenously formed gradients. pH sensing is likely to be biologically relevant as trypanosomes experience large differences in pH as they progress through their tsetse fly host. In addition, self-generated gradients may help reinforce directionality. Moreover, since trypanosomes encode a large family of adenylate cyclases, these may govern other chemotactic responses and tissue tropisms in both the mammal and the fly.