The Boston Red Sox parted ways with designated hitter/first baseman Hanley Ramirez on Friday, designating him for assignment. Associated Press/Charles Krupa

The Boston Red Sox have cut ties with first baseman/DH Hanley Ramirez, designating him for assignment Friday.

The move opens a roster spot for second baseman Dustin Pedroia, who was activated from the disabled list. He has missed all season after having surgery on his left knee in October.

The Red Sox have seven days to either trade Ramirez or release him.

The roster move comes as a surprise, given that Ramirez had started 44 of Boston’s 50 games this season and typically batted No. 3 in the Red Sox lineup. Twenty-five of his starts were at first base and 19 as the designated hitter.

Ramirez, 34, had been with the Red Sox since 2015 after signing a four-year, $88 million contract as a free agent.

During his four seasons with Boston, Ramirez batted .260 with 78 homers and 255 RBIs. This year he had a .254 batting average with six home runs and 29 RBI, but since the start of May he is batting .163 with three homers in 80 at bats. He was hitless in his last 21 at bats.

He is still owed $15 million this year. Ramirez also had a vesting option for next season, based on his plate appearances. By designating him, Boston will not have to pay that option for next year, saving $22 million in 2019.

Both of Boston’s big free-agent signings ahead of the 2015 season have been designated for assignment. Third baseman Pablo Sandoval was given a $95 million, five-year deal and released last July 19. The Red Sox are responsible for the vast majority of Sandoval’s $18 million salary this year, with the $545,000 he is earning from San Francisco offset against the total. Boston also owes Sandoval $18 million for 2019.

There was speculation was that the Red Sox would designated Blake Swihart to make room for Pedroia. Swihart, the No. 3 catcher and a rarely used left fielder, has appeared in only 17 games for Boston. Swihart, a switch-hitter, can now see more time at designated hitter. Mitch Moreland will take over first base full time. Moreland is batting .311 with seven home runs.

Pedroia, 34, had been Boston’s opening day second baseman every year from 2007-17. He was the American League Rookie of the Year in 2007 and Most Valuable Player in 2008.