The number of longhorn beetles with confirmed aggregation-sex pheromones has increased rapidly in recent years. However, the species that have been studied most intensively are pests, whereas much less is known about the pheromones of longhorn beetles that are rare or threatened. We studied the cerambycid beetle Plagionotus detritus ssp. detritus with the goal of confirming the presence and composition of an aggregation-sex pheromone. This species has suffered widespread population decline due to habitat loss in Western Europe, and it is now considered threatened and near extinction in several countries. Beetles from a captive breeding program in Sweden were used for headspace sampling. Gas chromatography-mass spectrometry revealed that collections from males contained large quantities of two compounds, identified as (R)-3-hydroxy-2-hexanone (major component) and (S)-2-hydroxy-3-octanone (minor component), in addition to smaller quantities of 2,3-hexanedione and 2,3-octanedione. None of the compounds was present in collections from females. When tested singly in a field bioassay, racemic 3-hydroxy-2-hexanone and 2-hydroxy-3-octanone were not attractive to P. detritus, whereas a 5:1 blend elicited significant attraction. Both compounds are known as components of the pheromones of conspecific beetles, but, to our knowledge, this is the first cerambycid shown to use two compounds with different chain lengths, in which the positions of the hydroxyl and carbonyl functions are interchanged between the two. The pheromone has potential as an efficient tool to detect and monitor populations of P. detritus, and may also be useful in more complex studies on the ecology and conservation requirements of this species.