The methylammonium lead iodide perovskite (MAPbI3) is presently a desirable material for photovoltaic application. Its structure is orthorhombic at low temperature and tetragonal at room temperature. Most theoretical works have focused on either tetragonal or orthorhombic phase alone leaving a gap in the understanding of the structural phase transition in between. In this work, by ab initio calculations, we elucidate the origin of structural phase transition between these two phases. We show that there exists a critical ratio of out-of-plane to in-plane lattice constants, c/a ∼ 1.45, where at low c/a the orthorhombic Pnma phase is stable while the tetragonal I4/mcm phase is stable at high c/a. Varying the c/a ratio leads to a change of PbI6 octahedral tilting with the rotation of CH3NH3(+) cations about the NH3 component in and out of the Oxy plane. The origin of this rotation is identified. We propose that under epitaxial conditions a gradual change in structural phase of the MAPbI3 perovskite may exist and understanding its electronic properties will be beneficial toward the solar cell community.