The inversion from L- to D-stereochemistry endows peptides improved bioactivity and enhanced resistance to many proteases and peptidases. To strengthen the biostability and bioavailability of peptide drugs, enzymatic epimerization becomes an important way to incorporate D-amino acid into peptide backbones. Recently, a bifunctional thioesterase NocTE, which is responsible for the epimerization and hydrolysis of the C-terminal (p-hydroxyphenyl)glycine residue of β-lactam antibiotic nocardicin A, exclusively directs to the generation of D-diastereomers. Different from other epimerases, NocTE exhibits unique stereochemical selectivity. Herein, we investigated the catalytic mechanism of NocTE via molecular dynamic (MD) simulations and quantum mechanical/molecular mechanics (QM/MM) calculations. Through structural analyses, two key water molecules around the reaction site were found to serve as proton mediators in epimerization. The structural characteristics inspired us to propose a substrate-assisted mechanism for the epimerization, where multi-step proton transfers were mediated by water molecules and β-lactam ring, and the free energy barrier was calculated to be 20.3 kcal/mol. After that, the hydrolysis of D-configured substrate was energetically feasible with the energy barrier of 14.3 kcal/mol. As a comparison, the energy barrier for the direct hydrolysis of L-configured substrate was obtained to be 24.0 kcal/mol. Our study provides mechanistic insights into catalytic activities of bifunctional thioesterase NocTE, uncovers more clues to the molecular basis for stereochemical selectivity and paves the way for the directed biosynthesis of novel peptide drugs with various stereostructural characteristics by enzyme rational design.