The QM/MM model was prepared by deleting the solvent beyond 30 Å from the C1 atom of the ligand, based on protein-substrate complex equilibrated by classical MD simulations (Supplementary Classical MD simulations). Due to the restraints imposed in classical MD, we first subjected the system to a 5 ps unrestrained QM/MM MD process to alleviate potential tensions. The equilibrated structure was then used for subsequent potential energy scan (PES) processes with the reaction coordinate driving method . For the selection of the QM region, the carbocations, the three Mg 2+ ions, and the PPi group, along with the aromatic residues Phe93, F221, and Trp335, were included in the QM region during the QM/MM MD and potential energy scan (PES) calculations from D + to product 3. These residues were chosen because of their proximity to the intermediates and their potential role in stabilizing the carbocations. The Mg 2+ cluster and PPi group were removed from QM region during the PES calculations from A + to C + , as these rearrangements do not involve the participation of PPi group. For the definition of reaction coordinates, please refer to Supplementary Figure . All atoms in the QM subsystem were treated by M06-2X/6-31G(d) method , which is widely used in studies of cyclization reactions . The QM/MM boundary was treated by the improved pseudo approach . The Amber FF99SB force field was used for all the remaining atoms, consistent with previous classical MD simulations. Spherical boundary condition was employed to the system, with the atoms located more than 30 Å from the spherical center being fixed. A 12 Å cutoff was used for van der Waals interactions, while an 18 Å cutoff was employed for electrostatic interactions. The system temperature was controlled by Langevin thermostat method at 300K, and the Newton equation of motion was integrated by the Beeman algorithm during the QM/MM MD process. All these QM/MM calculations were performed with the modified QChem and Tinker 69 programs developed by Prof. Yingkai Zhang's group (). And the similar QM/MM protocol had also been employed in our previous studies of other TPSs . The calculation of the relative binding energies was described in detail in Supplementary Binding energy calculation.