The reactions of enzymes and cofactors with gaseous molecules such as dioxygen (O2) are challenging to study and remain among the most contentious subjects in biochemistry. To date, it is largely enigmatic how enzymes control and fine-tune their reactions with O2, as exemplified by the ubiquitous flavin-dependent enzymes that commonly facilitate redox chemistry such as the oxygenation of organic substrates. Here we employ O2-pressurized X-ray crystallography and quantum mechanical calculations to reveal how the precise positioning of O2 within a flavoenzyme's active site enables the regiospecific formation of a covalent flavin-oxygen adduct and oxygenating species (i.e., the flavin-N5-oxide) by mimicking a critical transition state. This study unambiguously demonstrates how enzymes may control the O2 functionalization of an organic cofactor as prerequisite for oxidative catalysis. Our work thus illustrates how O2 reactivity can be harnessed in an enzymatic environment and provides crucial knowledge for future rational design of O2-reactive enzymes.