Flavoproteins catalyse a diversity of fundamental redox reactions and are one of the most studied enzyme families. As monooxygenases, they are universally thought to control oxygenation by means of a peroxyflavin species that transfers a single atom of molecular oxygen to an organic substrate. Here we report that the bacterial flavoenzyme EncM catalyses the peroxyflavin-independent oxygenation-dehydrogenation dual oxidation of a highly reactive poly(β-carbonyl). The crystal structure of EncM with bound substrate mimics and isotope labelling studies reveal previously unknown flavin redox biochemistry. We show that EncM maintains an unexpected stable flavin-oxygenating species, proposed to be a flavin-N5-oxide, to promote substrate oxidation and trigger a rare Favorskii-type rearrangement that is central to the biosynthesis of the antibiotic enterocin. This work provides new insight into the fine-tuning of the flavin cofactor in offsetting the innate reactivity of a polyketide substrate to direct its efficient electrocyclization.