Adenosine triphosphate (ATP) hydrolysis is a well-known biological reaction which plays an important role in many biological processes. In this study, we have modelled the non-enzymatic hydrolysis of ATP in the gas-phase and the aqueous-phase by performing ab initio molecular dynamics simulations combined with an enhanced sampling technique. In the gas-phase, we studied hydrolysis of fully protonated ATP molecule and in the aqueous-phase, we studied hydrolysis of ATP coordinated with: a) two H+ ions (H-ATP), b) Mg2+ (Mg-ATP) and c) Ca2+ (Ca-ATP). We show that gas-phase ATP hydrolysis follows a two-step dissociative mechanism via a highly stable metaphosphate intermediate. The Adenine group of the ATP molecule plays a crucial role of a general base; temporarily accepting protons and, thus helping in the elimination-addition process. In the aqueous-phase hydrolysis of ATP, we find that the cage of solvent molecules increases the stability of the terminal phospho-anhydride bond through a well-known cage-effect. Further, we find that the aqueous-phase hydrolysis happens with the help of nearby water molecules, which assumes the role of a base assisting in proton diffusion through Grotthuss mechanism. We obtained much lower free-energy barriers for the aqueous-phase hydrolysis of ATP coordinated with divalent ions (Mg2+ and Ca2+) compared to hydrolysis of ATP coordinated with only H+ ions, suggesting a clear catalytic effect of the divalent ions. We find a single-step dissociative-type mechanism for Mg-ATP, while we find a SN-2-type concerted hydrolysis pathway for Ca-ATP.