Sex-specific trait expression is frequently associated with highly variable, condition-dependent expression within sexes and rapid divergence among closely related species. Horned beetles are an excellent example for studying the molecular basis of these phenomena because horn morphology varies markedly among species, between sexes, and among alternative, nutritionally-cued morphs within sexes. In addition, horns lack obvious homology to other insect traits and provide a good opportunity to explore the molecular basis of the rapid diversification of a novel trait within and between species. Here we show that the sex-determination gene doublesex (dsx) underlies important aspects of horn development, including differences between sexes, morphs, and species. In male Onthophagus taurus, dsx transcripts were preferentially expressed in the horns of the large, horned morph, and RNAimediated knockdown of dsx dramatically altered male horn allometry by massively reducing horn development in large males, but not in smaller males. Conversely, dsx RNAi induced ectopic, nutrition-sensitive horn development in otherwise hornless females. Finally, in a closely related species (Onthophagus sagittarius) that has recently evolved a rare reversed sexual dimorphism, dsx RNAi revealed reversed as well as novel dsx functions despite an overall conservation of dsx expression. This suggests that rapid evolution of dsx functions has facilitated the transition from a regular sexual dimorphism to a reversed sexual dimorphism in this species. Our findings add beetle horns to existing examples of a close relationship between dsx and sexual trait development, and suggest that dsx function has been coopted to facilitate both the evolution of environmentally-cued intrasexual dimorphisms and rapid species divergences in a novel trait.cooption | polyphenism | evolutionary novelty | interchangeability | weak linkage