This study examines microstructural modification as an effective strategy for reducing corrosion and its impact on the mechanical properties of mild steel. The effect of heat treatment on morphology, strength, toughness, and ductility was studied using optical microscopy, SEM, Scherrer equation, Vickers’s hardness test, and tensile-strength measurement. The heat treatment changed the microstructures, grain sizes, and particle sizes of the samples. It also increased the material strength by 56% and 25% for the quenched and tempered samples, respectively. The hardness was increased to 95% by quenching. The effect of the microstructural changes on the corrosion rate in chlorine-rich and chlorine-free media at different pH was studied using linear-polarization-resistance and dynamic-polarization-resistance methods. In both media, the quenched samples showed a lower corrosion rate compared to the original and tempered samples. The heat treatment resulted in the formation of homogenous martensite with coarse grains and small particle sizes that seemed to reduce the corrosion rate significantly. It also had an impact on the corrosion mechanism of these materials. The original and tempered samples showed pitting-corrosion behavior with high corrosion rates, while the quenched samples were more susceptible to intergranular corrosion. The rate of corrosion was investigated further at different pH, and it was shown to decrease when the pH was raised. This study confirms the impact of microstructural changes on the corrosion behavior of S275 structural steel.