RICHMOND, Calif. — Chevron Corp. and state regulators have reached a settlement related to a 2012 fire at its Richmond refinery that will require the company to spend about $20 million on safety improvements, officials announced Monday.

The agreement requires Chevron to replace all carbon steel piping that transports corrosive liquids with chrome-alloy piping, which is better at resisting corrosion. Chevron will also have to implement procedures to monitor equipment that alerts operators when replacements are needed, Cal/OSHA, the state’s workplace safety agency, said in a statement.

“This means safer operations at the refinery, which will help protect refinery workers and those who work and live nearby,” Cal/OSHA Chief Juliann Sum said.

In 2013, the state fined Chevron nearly $1 million after a fire at the company’s Richmond refinery sent a cloud of gas and black smoke over residential areas.

Investigators found “willful violations” in Chevron Corp.’s response before, during and after the Aug. 6, 2012, fire caused by an old, leaky pipe in one of the facility’s crude units that the company had neglected to replace, even after inspecting areas near the segment that failed less than a year earlier. Cal/Osha also said at the time the company didn’t follow recommendations its own inspectors and scientists made in 2002 to replace the corroded pipe that ultimately ruptured and caused the fire.

Smoke and gas from the blaze prompted thousands of people to seek medical treatment, with many complaining of eye irritation and breathing problems. No workers were seriously injured in the incident.