  Megabar pressures are of crucial importance for cutting-edge studies of
condensed matter physics and geophysics. With the development of diamond anvil
cell, laboratory studies of high pressure have entered the megabar era for
decades. However, it is still challenging to implement in-situ magnetic sensing
under ultrahigh pressures. Here, we demonstrate optically detected magnetic
resonance of diamond nitrogen-vacancy (NV) centers, a promising quantum sensor
of strain and magnetic fields, up to 1.4 Mbar. We quantify the reduction and
blueshifts of NV fluorescence under high pressures. We demonstrate coherent
manipulation of NV electron spins and extend its working pressure to the
megabar region. These results shed new light on our understanding of diamond NV
centers and will benefit quantum sensing under extreme conditions.
