Many animal species are comprised of discrete phenotypic forms. Understanding the genetic mechanisms generating and maintaining such phenotypic variation within species is essential to comprehending morphological diversity. A common and conspicuous example of discrete phenotypic variation in natural populations of insects is the occurrence of different colour patterns, which has motivated a rich body of ecological and genetic research. The occurrence of dark, i.e. melanic, forms, displaying discrete colour patterns, is found across multiple taxa, but the underlying genomic basis remains poorly characterized. In numerous ladybird species (Coccinellidae), the spatial arrangement of black and orange patches on adult elytra varies wildly within species, forming strikingly different complex colour patterns. In the harlequin ladybird Harmonia axyridis, more than 200 distinct colour forms have been described, which classic genetic studies suggest result from allelic variation at a single, unknown, locus. Here, we combined whole-genome sequencing, population genomics, gene expression and functional analyses, to establish that the gene pannier controls melanic pattern polymorphism in H. axyridis. We show that pannier, which encodes an evolutionary conserved transcription factor, is necessary for the formation of melanic elements on the elytra. Allelic variation in pannier leads to protein expression in distinct domains on the elytra, and thus determines the distinct colour patterns in H. axyridis. Recombination between pannier alleles may be reduced by a highly divergent sequence of ca. 170 kb in the cis-regulatory regions of pannier with a 50 kb inversion between colour forms. This likely helps maintaining the distinct alleles found in natural populations. Thus we propose that highly variable discrete colour forms can arise in natural populations through cis-regulatory allelic variation of a single gene.