Federal law requires pipelines to have cathodic protection, an electrochemical system of controlling corrosion.
Alternating current from a power line is converted to low-voltage direct current.
Current flows to the anode (a piece of magnesium of other metal buried in the ground).
Electrons from the anode flow through the soil toward the pipeline. The electrochemical reaction causes the anode to corrode instead of the pipeline.
Current flows from the anode through the pipeline to a wire and completes the circuit.