Rocky planets are thought to comprise compounds of Mg and O as these are among the most abundant elements, but knowledge of their stable phases may be incomplete. MgO is known to be remarkably stable to very high pressure and chemically inert under reduced condition of the Earths lower mantle. However, in icy gas giants as well as in exoplanets oxygen may be a more abundant constituent (Ref. 1,2). Here, using synchrotron x-ray diffraction in laser-heated diamond anvil cells, we show that MgO and oxygen react at pressures above 94 GPa and T = 2150 K with the formation of the theoretically predicted I4/mcm MgO2 (Ref.3). Raman spectroscopy detects the presence of a peroxide ion (O22-) in the synthesized material as well as in the recovered specimen. Likewise, energy-dispersive x-ray spectroscopy confirms that the recovered sample has higher oxygen content than pure MgO. Our finding suggests that MgO2 may substitute MgO in rocky mantles and rocky planetary cores under highly oxidizing conditions.