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.
The Pittsburgh Pirates announced Monday that they have agreed to terms with Norwalk pitcher Joel Hanrahan on a one-year deal that's worth $4.1 million.
Closer recorded 40 saves in 2011.