The color of firefly bioluminescence is determined by the structure of luciferase. Firefly luciferase genes have been isolated from more than 30 species, producing light ranging in color from green to orange-yellow. Here, we reconstructed seven ancestral firefly luciferase genes, characterized the enzymatic properties of the recombinant proteins, and determined the crystal structures of the gene from ancestral Lampyridae. Results showed that the synthetic luciferase for the last common firefly ancestor exhibited green light caused by a spatial constraint on the luciferin molecule in enzyme, while fatty acyl-CoA synthetic activity, an original function of firefly luciferase, was diminished in exchange. All known firefly species are bioluminescent in the larvae, with a common ancestor arising approximately 100 million years ago. Combined, our findings propose that, within the mid-Cretaceous forest, the common ancestor of fireflies evolved green light luciferase via trade-off of the original function, which was likely aposematic warning display against nocturnal predation.