The hammerhead ribozyme is an RNA molecule capable of self-cleavage at a unique site within its sequence. Hydrolysis of this phosphodiester linkage has been proposed to occur via an in-line attack geometry for nucleophilic displacement by the 2'-hydroxyl on the adjoining phosphorus to generate a 2',3'-cyclic phosphate ester with elimination of the 5'-hydroxyl group, requiring a divalent metal ion under physiological conditions. The proposed S(N)2(P) reaction mechanism was investigated using density functional theory calculations incorporating the hybrid functional B3LYP to study this metal ion-dependent reaction with a tetraaquo magnesium (II)-bound hydroxide ion. For the Mg(2+)-catalyzed reaction, the gas-phase geometry optimized calculations predict two transition states with a kinetically insignificant, yet clearly defined, pentacoordinate intermediate. The first transition state located for the reaction is characterized by internal nucleophilic attack coupled to proton transfer. The second transition state, the rate-determining step, involves breaking of the exocyclic P-O bond where a metal-ligated water molecule assists in the departure of the leaving group. These calculations demonstrate that the reaction mechanism incorporating a single metal ion, serving as a Lewis acid, functions as a general base and can afford the necessary stabilization to the leaving group by orienting a water molecule for catalysis.