The evolutive origin of luciferin in bioluminescent beetles remains a mystery. Luciferin has cysteine and benzoquinone as precursors, and it can be spontaneously produced from these compounds under neutral buffer conditions. However, its biosynthetic pathway and alternative functions remain largely unveiled. We have set up a cellular bioluminescent sensing method for luciferin synthesis from cysteine and benzoquinone using E. coli and Pichia pastoris expressing the bright Amydetes vivianii firefly luciferase and P.termitilluminans click beetle luciferase. In the presence of D-cysteine and benzoquinone, intense bioluminescence is quickly by transformed E.coli, indicating the expected formation of D-luciferin. Starting with L-cysteine and benzoquinone, the bioluminescence is weaker and delayed in comparison with experiments starting with D-cysteine, indicating that bacteria expressing firefly luciferase first produce L-luciferin, and then racemize it to D-luciferin in the presence of endogenous bacterial esterases, CoA and firefly luciferase. Whereas p-benzoquinone is extremely toxic to bacteria (IC50 ~25 µM), in the presence of cysteine this toxicity is considerably reduced, maintaining cell viability even in higher concentrations of p-benzoquinone (3.6 mM). Transcriptional analysis of photogenic and non-photogenic tissues of fireflies, showed the presence of several gene products involved with the sclerotization/tanning pathways in the photogenic tissues, with the exception of enzymes involved with the last steps of these pathways, suggesting the possible accumulation of quinone intermediates in lanterns. These results and the high abundance of cysteine producing enzymes suggest that luciferin arose as a detoxification byproduct of the reaction of accumulated toxic quinone intermediates with cysteine during the sclerotization/tanning in Coleoptera.