The Red Sox have finished off a six-player trade with the Pirates that centered around righthanded reliever Joel Hanrahan, and manager John Farrell has told Hanrahan that he would be the closer going into spring training, Red Sox assistant general manager Brian O’Halloran said.

O’Halloran, speaking to reporters this afternoon as general manager Ben Cherington was traveling, said that Farrell spoke to Hanrahan and Andrew Bailey and told them that Hanrahan would be the closer going into spring training with Bailey as one of the set-up men.

“We see Andrew as playing a very important role in our bullpen as well,” O’Halloran said. “There will be plenty of opportunities for him to help us win games in key situations late in the game. We know he’s very capable both closing and pitching in other high-leverage situations at the end of games.”

In addition to Hanrahan, the Red Sox also obtained middle infield prospect Brock Holt from Pittsburgh in return for righthanded reliever Mark Melancon and three minor leaguers: infielder Ivan De Jesus Jr., righthander Stolmy Pimentel and first baseman/outfielder Jerry Sands.

De Jesus and Sands were among the five players the Red Sox obtained from the Los Angeles Dodgers in August for Josh Beckett, Carl Crawford, Adrian Gonzalez and Nick Punto.

Hanrahan, 31, will be a free agent after the season. He has 76 saves and a 2.24 earned run average over the last two seasons, striking out 128 over 128.1 innings.

”I’m very excited to be joining the Red Sox and look forward to joining the great history of Boston and making some new history!!!,” Hanrahan posted on Twitter shortly after the trade was announced.

Hanrahan had a dominant 2011 season, allowing only 16 walks over 68.2 innings and striking out 61. He had a 1.83 ERA. The big righthander slipped in 2012, walking 36 over 57.2 innings and posting a 2.72 ERA. But he did strikeout 67.

Hanrahan had a poor September, allowing five earned runs over 9 innings and walking 10 as the Pirates fell out of contention. He was offered arbitration by the Pirates and is in line for a one-year, $7 million deal in 2013. The Sox also could attempt to sign him to a longer-term deal.

Holt, 24, is a former ninth-round draft pick out of Rice University. He played 24 major league games for the Pirates in September, hitting .292 in 65 at-bats. Holt hit .322 with Double A Altoona over 102 games and .432 in 24 games for Triple A Indianapolis.

In all, Holt hit .344/.406/.453 in the minors this season. He is a career .317/.381/.427 hitter in four minor league seasons, albeit with only 11 home runs. Holt has 49 stolen bases. He projects as a backup player.

Melancon, who turns 28 in March, had a rocky one-year tenure in Boston. Obtained from Houston for Jed Lowrie and Kyle Weiland last December, Melancon started the season as the primary set-up man and lasted only four games before being demoted to Triple A Pawtucket.

Melancon gave up 11 earned runs over two innings in those appearances. He pitched fairly well when he returned to the team in June, particularly in September. But Melancon was used mainly in low-leverage situations and never gained the trust of former manager Bobby Valentine.

Once the closer in Houston, Melancon could return to that form in the National League.

Pimentel, 22, was once considered a strong prospect but has faded in recent years. He had a 4.59 ERA in 22 starts for Double A Portland last season.

DeJesus, 25, appeared in eight games for the Sox in September then was designated for assignment in November before being outrighted to Pawtucket.

Sands, 25, never played in the Sox organization. He was a player to be named later in the trade and came over on Oct. 4. Sands hit .296 with 26 home runs and 107 RBIs for Triple A Albuquerque last season.