Hanrahan, who was named to the National League’s all-star team last season and saved a career-high 40 games as Pittsburgh’s closer, made $1.4 million last season.
In 2011, the 6-foot-4, 245-pound Hanrahan struck out 61 batters in just under 69 innings with a 1.83 earned-run average.
The deal allows the team and Hanrahan, 30, to avoid an arbitration hearing.
The signing of Hanrahan leaves Garrett Jones, Jeff Karstens, Evan Meek, Charlie Morton, and Casey McGehee as the arbitration-eligible Pirates who have not yet agreed on contracts.