FLINT, Mich. — General Motors, the biggest employer in Flint, might also be its luckiest water customer.

Soon after Flint made its ill-fated switch in 2014 to Flint River water from the costlier Detroit municipal system, officials at GM’s engine plant here flagged a big problem: corrosion caused by high levels of chloride in the water.

“The water was rusting the [engine] blocks,” Dan Reyes, president of UAW Local 599, which represents the plant’s nearly 900 workers, recalled in an interview last week.

In December 2014, the plant switched from Flint’s tainted water system to a fresh supply from neighboring Flint Township -- an option that was not afforded other Flint residents and businesses.

As a result, the plant was able to sidestep a crisis that has befallen everyone else in the city where GM was born more than a century ago.

The workaround was made possible by the factory’s fortuitous location and some heads-up planning.

Plant officials were among the first people in Flint to detect something wrong. It was in summer 2014, many months before the problem of corroding lead pipes would morph into a public-health calamity and national media maelstrom.

For GM, the problem was not lead but the elevated levels of chloride in the treated river water -- added to remove solids and contaminants -- that began to cause “visible corrosion damage on parts coming out of the machining process,” GM spokesman Tom Wickham said last week.

The 1.2-million-square-foot plant makes engines used in the Buick Enclave crossover, Chevrolet Cruze compact and Colorado pickup and other vehicles.

For months, factory officials tried to make it work. They used reverse osmosis, an advanced and pricey purification process. Additional water was trucked in to dilute chloride levels. The remediation efforts proved time consuming and costly, Wickham said.