Tyler Thornburg is headed to the Boston Red Sox after the Milwaukee Brewers traded the right-handed reliever for third baseman Travis Shaw, minor league shortstop Mauricio Dubon and minor league righty Josh Pennington.

The Red Sox will also send a player to be named later and cash to the Brewers.

“It’s been real Boston. Excited for the opportunity ahead of me in Milwaukee! Looking forward to this next chapter of my career! #Brewers,” Shaw wrote on his Twitter account.

Thornburg, 28, helps bolster the back end of the Red Sox’s bullpen with free agents Koji Uehara and Brad Ziegler unsure to return. Thornburg is 14-9 with a 2.87 ERA and 220 strikeouts in 144 games over five seasons.

In 2016, Thornburg totaled 13 saves while going 8-5 with a 2.15 ERA in 67 appearances. Boston president of baseball operations Dave Dombrowski previously said he wanted to acquire a bullpen arm with closing experience.

Shaw, 26, beat out Pablo Sandoval to win the Red Sox’s starting job at third base last season. Shaw hit .242 with 16 homers and 71 RBIs in 145 games. He is a lifetime .251 hitter with 29 homers and 107 RBIs.

Shaw’s departure seems to indicate the Red Sox will stick with Sandoval at third next season. The former World Series MVP missed most of the 2016 season after undergoing shoulder surgery in early May.

The Brewers are seeking to balance what had been a predominantly right-handed lineup while also continuing to stockpile young talent to further their rebuilding process.

General manager David Stearns made significant progress on those fronts by sending Thornburg to the Red Sox for Shaw and Dubon and right-hander Josh Pennington. The Brewers also will get a player to be named later or cash in the deal.

Though it continued to thin the back of his bullpen, Stearns called it “a deal we couldn’t pass up” and it was easy to see why. In Shaw and recently acquired first baseman Eric Thames, the Brewers have added two left-handed hitters with power to their lineup.

The plan is for Shaw, 26, to be the primary third baseman, a role he filled for the Red Sox last season while also seeing time at first base. As expected, Jonathan Villar — who moved from shortstop to third when Arcia came up from the minors at the outset of August — will shift to second base and see most of his action there, increasing the likelihood that Scooter Gennett will be traded.

“Shaw is certainly going to see a lot of time at third base,” Stearns said. “We like positional versatility. We like setting our lineup every day so that (manager) Craig (Counsell) has the best chance to put the best nine players out there against the opposing pitcher. We certainly anticipate that Travis is going to be among that group regularly.”

Shaw struggled against left-handed pitchers (.599 OPS) last season and if that continues it provides the opportunity for the right-handed-hitting Hernan Perez to see action as well at third base.

Shaw said he believes he can hit left-handed pitchers if given the chance and said he looked forward to proving that with the Brewers.

“I had success my first year up in the big leagues; I hit lefties pretty well (.975 OPS in 85 plate appearances in 2015),” he said. “Last year, I didn’t get many opportunities against them earlier in the year. I got pinch-hit for a lot early in the year, and then when we traded (with Milwaukee) for Aaron Hill, I never played against lefties the rest of the year after that.

“Last year was a little bit different for me. Pretty much, halfway through the year (I went) from playing every day to being a platoon player, and it was an adjustment for me. I feel like I can have some success against lefties. Hopefully, getting an opportunity to play every day, that will work itself out again.”

As for the trade itself, Shaw said, “I’m not really familiar with anybody in the Brewers organization. It’s a completely different league. I’ve never even been to Milwaukee, so this will all be new to me. I’ve been with the Red Sox my whole career. Later today, I’ll be personally trying to figure out where I fit on this team going into 2017.”