The coexistence and competition between superconductivity and electronic orders, such as spin or charge density waves, have been a central issue in high transition-temperature (\({T_{\rm c}}\)) superconductors. Unlike other iron-based superconductors, FeSe exhibits nematic ordering without magnetism whose relationship with its superconductivity remains unclear. More importantly, a pressure-induced fourfold increase of \({T_{\rm c}}\) has been reported, which poses a profound mystery. Here we report high-pressure magnetotransport measurements in FeSe up to \(\sim9\) GPa, which uncover a hidden magnetic dome superseding the nematic order. Above \({\sim6}\) GPa the sudden enhancement of superconductivity (\({T_{\rm c}\le38.3}\) K) accompanies a suppression of magnetic order, demonstrating their competing nature with very similar energy scales. Above the magnetic dome we find anomalous transport properties suggesting a possible pseudogap formation, whereas linear-in-temperature resistivity is observed above the high-\({T_{\rm c}}\) phase. The obtained phase diagram highlights unique features among iron-based superconductors, but bears some resemblance to that of high-\({T_{\rm c}}\) cuprates.