Lets first look at the structures. Shown below are firefly luciferin, luciferyl adenylate (luciferin attached to AMP), and oxyluciferin.

Another major player in the light emission from fireflies is the luciferase enzyme which mediates the entire set of reactions. The basic mechanism is as follows:
- Luciferin and ATP react to form luciferyl adenylate and inorganic phosphate (PPi)
- Luciferyl adenylate reacts with oxygen to form oxyluciferin*, CO2, and AMP (the * indicates an excited electronic state)
- The excited oxyluciferin* rapidly loses a photon of visible light as it goes to its electronic ground state.
- Ground state oxyluciferin is then regenerated into luciferin through a number of different steps.
This is summerized in the figure below.

For a more detailed explanation see Dr. Branchini's page on firefly bioluminescence, including information on the luciferase enzyme.