We present a stoichiometry-dependent structural phase transition in SrRuO3 film on SrTiO3 substrate. The oxygen stoichiometry in the films was varied by changing the oxygen partial pressure P(O2) during the deposition process. For SrRuO3 films with P(O2) ≥ 60 mTorr, they exhibited a pseudo-orthorhombic structure with in-plane uniaxial magnetic anisotropy. On the other hand for films with P(O2) ≤ 45 mTorr, the tetragonal SrRuO3 phase with a perpendicular uniaxial magnetic anisotropy was stabilized at room temperature. The big difference in the magnetic anisotropy of these two SrRuO3 phases was shown to be closely linked to their respective RuO6 octahedral rotation patterns: the RuO6 octahedra rotate differently along the two orthogonal in-plane directions in the pseudo-orthorhombic phase, whereas in the tetragonal phase only octahedral rotations around z-axis are present and the octahedral tilts along the in-plane axes are diminished. First-principles calculations show that such a suppression of the RuO6 octahedra tilting in the tetragonal phase arises from the oxygen vacancies at the octahedral apex (along z-axis). This work demonstrates that the stoichiometry plays an important role in determining the octahedral rotations and tilts in the perovskite materials, which may induce new phases with distinctively different structural symmetry and physical property.