The more active metal corrodes first (hence the term "sacrificial") and generally must oxidize nearly completely before the less active metal will corrode, thus acting as a barrier against corrosion for the protected metal.
More scientifically, a sacrificial anode can be defined as a metal that is more easily oxidized than the protected metal. Electrons are stripped from the anode and conducted to the protected metal, which becomes the cathode. The cathode is protected from corroding, i.e., oxidizing, because reduction rather than oxidation takes place on its surface.
For example when zinc and iron are electrically connected in the presence of oxygen and water, the zinc will lose electrons and go into solution as zinc cations. Electrons released from the zinc atoms flow through metallic conduction to the iron where, on the surface, dissolved oxygen is reduced, by gaining the electrons released by the zinc, to hydroxide anions. Were the zinc not present, the same reduction of oxygen to hydroxide would occur on the iron surface. However in that case the electrons for reduction would be furnished by the iron, thus oxidizing the iron. Therefore, the zinc, when present,is "sacrificed" by being oxidized instead of the iron. The iron is "safe" until all of the zinc has corroded. As zinc is more costly than iron, this method of protecting iron, or steel, would not be cost effective were it not for secondary chemical reactions that form coatings on the iron surface, thus reducing the electrochemical reaction to a trickle and greatly prolonging the life of the zinc anode.
Other examples of protection by use of sacrificial anodes include protection of voids in the glass lining of mild steel water heater tanks via use of magnesium or aluminum alloy anodes, protection of off-shore oil rigs via special alloy anodes for use in salt water, protection of lock gates in water ways, etc.
It is important to understand that for this mode of corrosion protection to function there must be simultaneously present an electron pathway between the anode and the metal to be protected (e.g.,a wire or direct contact) and an ion pathway between the anode and the metal to be protected (e.g., water or moist soil) to form a closed circuit; thus simply bolting a piece of active metal such as zinc to a less- active metal, such as mild steel, in air will not furnish any protection.