Chemically induced nociception has not yet been studied intensively in genetically tractable models. Hence, our goal was to establish a Drosophila assay that can be used to study the cellular and molecular/genetic bases of chemically induced nociception. Drosophila larvae exposed to increasing concentrations of hydrochloric acid (HCl) produced an increasingly intense aversive rolling response. HCl (0.5%) was subthreshold and provoked no response. All classes of peripheral multidendritic (md) sensory neurons (classes I-IV) are required for full responsiveness to acid, with class IV making the largest contribution. At the cellular level, classes IV, III and I showed increases in calcium following acid exposure. In the central nervous system, Basin-4 second-order neurons are the key regulators of chemically induced nociception, with a slight contribution from other types. Finally, chemical nociception can be sensitized by tissue damage. Subthreshold HCl provoked chemical allodynia in larvae 4 h after physical puncture wounding. Pinch wounding and UV irradiation, which do not compromise the cuticle, did not cause chemical allodynia. In sum, we developed a novel assay to study chemically induced nociception in Drosophila larvae. This assay, combined with the high genetic resolving power of Drosophila, should improve our basic understanding of fundamental mechanisms of chemical nociception. This article is part of the Theo Murphy meeting issue 'Evolution of mechanisms and behaviour important for pain'.