Meteorites and diamonds encounter high pressures during their formation or subsequent evolution. These materials commonly contain magnetic inclusions of pyrrhotite. Because magnetic properties are sensitive to strain, pyrrhotite can potentially record the shock or formation pressures of its host. Moreover, pyrrhotite undergoes a pressure-induced phase transition between 1.6 and 6.2 GPa, but the magnetic signature of this transition is poorly known. Here we report room temperature magnetic measurements on multidomain and single-domain pyrrhotite under nonhydrostatic pressure. Magnetic remanence in single-domain pyrrhotite is largely insensitive to pressure until 2 GPa, whereas the remanence of multidomain pyrrhotite increases 50% over that of initial conditions by 2 GPa, and then decreases until only 33% of the original remanence remains by 4.5 GPa. In contrast, magnetic coercivity increases with increasing pressure to 4.5 GPa. Below ∼1.5 GPa, multidomain pyrrhotite obeys Néel theory with a positive correlation between coercivity and remanence; above ∼1.5 GPa, it behaves single domain-like yet distinctly different from uncompressed single-domain pyrrhotite. The ratio of magnetic coercivity and remanence follows a logarithmic law with respect to pressure, which can potentially be used as a geobarometer. Owing to the greater thermal expansion of pyrrhotite with respect to diamond, pyrrhotite inclusions in diamonds experience a confining pressure at Earth's surface. Applying our experimentally derived magnetic geobarometer to pyrrhotite-bearing diamonds from Botswana and the Central African Republic suggests the pressures of the pyrrhotite inclusions in the diamonds range from 1.3 to 2.1 GPa. These overpressures constrain the mantle source pressures from 5.4 to 9.5 GPa, depending on which bulk modulus and thermal expansion coefficients of the two phases are used.