Water tank with sacrificial anode.
A sacrificial anode is an anode (positive electrode) that is attached to a metal object to protect the object from corrosion. In the case of a water heater tank, a sacrificial anode takes the form of a metal rod that is placed in the tank. Anodes of aluminum, magnesium, or zinc are the more frequently used metals. The anode creates a galvanic cell in which magnesium or zinc will be corroded more quickly than the metal of the tank, giving the tank a negative charge and preventing corrosion.
Once the anode has been eaten away the tank itself will begin to corrode, so it's important to check the anode periodically and replace it when necessary. Typically the the anode is screwed into the top of the tank. Alternatively, it may be built into a special outlet fitting.