The primary objective of this study is to investigate the corrosion resistance of Fe‐36Ni Invar alloys with varying Mg contents in a 3.5 wt% sodium chloride solution. The electrochemical results reveal that the incorporation of Mg amplified the corrosion behavior of Fe‐36Ni Invar alloy. The inclusion compositions undergo a transformation with the increase of Mg content, evolving from MnO–MnS in 0 Mg alloy to MnO–MnS–MgO in 0.0015 Mg alloy, and ultimately to MnS–MgO–MgS in 0.0030 Mg alloy. During the corrosion process, the small‐sized MnS–MgO–MgS inclusions exhibit greater stability compared to the MnO–MnS inclusions, rendering them less susceptible to attack and dissolution. Adding Mg diminishes the size and number density of inclusions, which effectively decreases the susceptibility to pitting initiation. The introduction of Mg refines the microstructure and elevates the fraction of twin boundaries, which also is responsible for the enhancement of corrosion resistance.