Grid-scale energy storage applications can benefit from rechargeable sodium-ion batteries. As a potential material for making non-cobalt, nickel-free, cost-effective cathodes, earth-abundant Na2/3Fe1/2Mn1/2O2 is of particular interest. However, Mn3+ ions are particularly susceptible to the Jahn-Teller effect, which can lead to an unstable structure and continuous capacity degradation. Modifying the crystal structure by aliovalent doping is considered an effective strategy to alleviate the Jahn-Teller effect. Using a sol-gel synthesis route followed by heat treatment, we succeeded in preparing an Mg-doped Na2/3Fe1-yMnyO2 cathode. Its electrochemical properties and charge compensation mechanism were then studied using synchrotron-based X-ray absorption spectroscopy and in situ X-ray diffraction techniques. The results revealed that Mg doping reduced the number of Mn3+ Jahn-Teller centers and alleviated high voltage phase transition. However, Mg doping was unable to suppress the P2-P'2 phase transition at a low voltage discharge. An initial discharge capacity of about 196 mAh g-1 was obtained at a current density of 20 mAh g-1, and 60% of rate capability was maintained at a current density of 200 mAh g-1 in a voltage range of 1.5-4.3 V. This study will greatly contribute to the ongoing search for advanced and efficient cathodes from earth-abundant elements for rechargeable sodium-ion batteries operable at room temperature.