I think the mechanism is complex and isn't well understood. From a quick google search:
Hydrogen sulfide is a weak acid when dissolved in water, and can act as a catalyst in the absorption of atomic hydrogen in steel, promoting sulfide stress cracking (SSC) in high strength steels. Polysulfides and sulfanes (free acid forms of polysulfides) may be formed when hydrogen sulfide reacts with elemental sulfur. These sulfanes are produced along with other gaseous constituents. As pressure decreases up the production tubing, the sulfanes dissociate and elemental sulfur precipitates, which can cause plugging.
Iron sulfides are often formed from corrosion reactions, and can be important in corrosion control, especially at lower temperatures and low H2S partial pressures, where a protective film often forms.
Corrosion products include black or blue-black iron sulfides, pyrite, greigite, mackinwaite, kansite, iron oxide (Fe3O4), magnetite, sulfur (S), and sulfur dioxide (SO2).
http://octane.nmt.edu/waterquality/corrosion/H2S.htm