The deal, which includes $2.5 million in performance bonuses, gives the Pirates a right-handed option at first base to join left-handed slugger Pedro Alvarez, who is moving from third to first.
The 32-year-old Hart hit .203 with six home runs and 21 RBI in 68 games for the Seattle Mariners in 2014, most of them as a designated hitter, and became a free agent in October when he refused an outright assignment to the minor leagues. He missed the 2013 season due to surgeries on both knees.
Hart is a career .271 hitter was a two-time All-Star while playing for Milwaukee in 2008 and 2010. He set career highs with 31 homers and 103 RBI in 2010 and hit .270 with 30 homers and 83 RBI in his last full year with Milwaukee in 2012.
Hart can earn $250,000 each for 350, 375, 400 and 425 plate appearances, and $300,000 apiece for 450, 475, 500, 525 and 550.