Hudson, 29, will make $5.5 million in both 2017 and 2018. The contract includes $1.5 million annually in performance bonuses based on games finished starting at 30 and ending at 60.
As a member of the Arizona Diamondbacks all of last season, Hudson went 3-2 and posted a 5.22 ERA in 70 games.
Hudson, a former starter who became a reliever after undergoing reconstructive elbow surgery on his right (throwing) elbow in 2012 and 2013, thanked the Diamondbacks in a statement on his Twitter account for sticking with him "through some really tough times.'' He later added "Let's do this Pittsburgh.''
The 2016 season was somewhat of a down year for the 29-year-old, who had a 3.86 ERA and 71 strikeouts in 67 2/3 innings in 2015.
Hudson's addition gives the Pirates some flexibility in their bullpen heading into spring training. Tony Watson finished with 15 saves last season after taking over the closer's role when All-Star Mark Melancon was dealt to Washington at the trade deadline.
ESPN's Jim Bowden and The Associated Press contributed to this report.