In the solar system, oldhamite (CaS) is generally considered to be formed by the condensation of solar nebula gas. Enstatite chondrites, one of the most important repositories of oldhamite, are believed to be the representative of the material which formed Earth. Thus, the formation mechanism and the evolution process of oldhamite are of great significance to the deep understanding of the solar nebula, meteorites, the origin of Earth, and the C-O-S-Ca cycles of Earth. Until now, oldhamite has not been reported to occur in mantle rock. However, here we show the formation of oldhamite through the reaction between sulfide-bearing orthopyroxenite and molten CaCO3 at 1.5 GPa/1510 K, 0.5 GPa/1320 K, and 0.3 GPa/1273 K. Importantly, this reaction occurs at oxygen fugacities within the range of upper mantle conditions, 6 orders of magnitude higher than that of the solar nebula mechanism. Oldhamite is easily oxidized to CaSO4 or hydrolyzed to produce calcium hydroxide. Low oxygen fugacity of magma, extremely low oxygen content of the atmosphere, and the lack of a large amount of liquid water on the planet's surface are necessary for the widespread existence of oldhamite on the surface of a planet; otherwise, anhydrite or gypsum will exist in large quantities. Oldhamites may exist in the upper mantle beneath mid-ocean ridges. Additionally, oldhamites may have been a contributing factor to the early Earth's atmospheric hypoxia environment, and the transient existence of oldhamites during the interaction between reducing sulfur-bearing magma and carbonate could have had an impact on the changes in atmospheric composition during the Permian-Triassic Boundary.