Two homologous 2-oxoglutarate-dependent (ODD) nonheme enzymes thebaine 6-O-demethylase (T6ODM) and codeine-3-O-demethylase (CODM), are involved in the morphine biosynthesis pathway from thebaine, catalyzing the O-demethylation reaction with precise regioselectivity at C6 and C3 positions of thebaine respectively. We investigated the origin of the regioselectivity of these enzymes by combined molecular dynamics (MD) and quantum mechanics/molecular mechanics (QM/MM) calculations and found that Thebaine binds at the two distinct sites of T6ODM and CODM, which determines the regioselectivity of the enzymes. A remarkable oxo rotation is observed in the decarboxylation process. Starting from the closed pentacoordinate configuration, the C-terminal lid adopts an open conformation in the octahedral Fe(IV) = O complex to facilitate the subsequent demethylation. Phe241 and Phe311 stabilize the substrate in the binding pocket, while Arg219 acts as a gatekeeper residue to stabilize the substrate. Our results unravel the regioselectivity in 2-OG dependent nonheme enzymes and may shed light for exploring the substrate scope of these enzymes and developing novel biotechnology for morphine biosynthesis.