Body odour is a characteristic trait of Homo sapiens, however its role in human behaviour and evolution is poorly understood. Remarkably, body odour is linked to the presence of a few species of commensal microbes. Herein we discover a bacterial enzyme, limited to odour-forming staphylococci that are able to cleave odourless precursors of thioalcohols, the most pungent components of body odour. We demonstrated using phylogenetics, biochemistry and structural biology that this cysteine-thiol lyase (C-T lyase) is a PLP-dependent enzyme that moved horizontally into a unique monophyletic group of odour-forming staphylococci about 60 million years ago, and has subsequently tailored its enzymatic function to human-derived thioalcohol precursors. Significantly, transfer of this enzyme alone to non-odour producing staphylococci confers odour production, demonstrating that this C-T lyase is both necessary and sufficient for thioalcohol formation. The structure of the C-T lyase compared to that of other related enzymes reveals how the adaptation to thioalcohol precursors has evolved through changes in the binding site to create a constrained hydrophobic pocket that is selective for branched aliphatic thioalcohol ligands. The ancestral acquisition of this enzyme, and the subsequent evolution of the specificity for thioalcohol precursors implies that body odour production in humans is an ancient process.