Genetic analysis of interspecific populations derived from crosses between the wild tomato species Solanum habrochaites f. sp. glabratum, which synthesizes and accumulates insecticidal methylketones (MK), mostly 2-undecanone and 2-tridecanone, in glandular trichomes, and cultivated tomato (Solanum lycopersicum), which does not, demonstrated that several genetic loci contribute to MK metabolism in the wild species. A strong correlation was found between the shape of the glandular trichomes and their MK content, and significant associations were seen between allelic states of three genes and the amount of MK produced by the plant. Two genes belong to the fatty acid biosynthetic pathway, and the third is the previously identified Methylketone Synthase1 (MKS1) that mediates conversion to MK of b-ketoacyl intermediates. Comparative transcriptome analysis of the glandular trichomes of F2 progeny grouped into low-and high-MK-containing plants identified several additional genes whose transcripts were either more or less abundant in the high-MK bulk. In particular, a wild species-specific transcript for a gene that we named MKS2, encoding a protein with some similarity to a well-characterized bacterial thioesterase, was approximately 300-fold more highly expressed in F2 plants with high MK content than in those with low MK content. Genetic analysis in the segregating population showed that MKS2's significant contribution to MK accumulation is mediated by an epistatic relationship with MKS1. Furthermore, heterologous expression of MKS2 in Escherichia coli resulted in the production of methylketones in this host.