BOSTON — Pablo Sandoval and Hanley Ramirez spent the last two years as NL West rivals. Now they’re Boston teammates, the result of a $183 million spending spree the Red Sox hope will get them out of the AL East cellar.

“It’s exciting for me to be with Hanley and David Ortiz,” Sandoval said Tuesday at Fenway Park after finishing up a five-year, $95 million contract that adds him to a lineup he called “The Three Amigos.”

About five hours later the Red Sox completed their day-night news conference doubleheader by announcing Ramirez’s four-year deal, which is worth $88 million. A former Red Sox prospect, Ramirez was traded to the Marlins nine Thanksgivings ago in a deal that brought Mike Lowell and Josh Beckett to Boston.

“Why not go back where you belong?” Ramirez said. “It worked out for the both of us: You guys won a couple of world championships. I haven’t won any but that’s what I’m here for.”

Sandoval helped the Giants win three titles, earning the World Series MVP in 2012 and the nickname “Kung Fu Panda” that helped cement him as a fan favorite. He thanked the Giants for bringing him up as a big leaguer and fans for their support.

“I want a new challenge. I need a new challenge,” he said. “I know that I had a great career in San Francisco, but I’m going to have a new one here.”

Sandoval helps fill a hole in the Red Sox lineup for a third baseman and a left-handed bat. Ramirez, who played shortstop and a little third base with the Marlins and Los Angeles Dodgers, is expected to move to left field.

“You’re always trying to get a sense of where they might fit in,” Manager John Farrell said. “We’re not even at Thanksgiving yet. The potential for some other additions might exist.”

Sandoval’s deal includes a team option for 2020 and Ramirez’s contract has a vesting option for 2019.

A 28-year-old Venezuelan listed at 5-foot-11 and 248 pounds, Sandoval was seen as a replacement at designated hitter when Ortiz retires. But Sandoval said he plans to manage his weight to stay in the field.

Both players praised Ortiz, and Ramirez also said Dustin Pedroia helped recruit him.

“He said, ‘I’ve got two rings. You don’t have any. I want some more,’ ” Ramirez said. “That kind of thing pumps you up.”

Sandoval said Ortiz gave him advice when he was in the minor leagues that he has carried with him. Having a chance to play with Ortiz, who was the Series MVP in 2013, was a factor.

“To be Papi’s teammate – 162 games, all that with him – for me it’s going to be very exciting,” said Sandoval, who had dinner Monday night with Ramirez. Ramirez agreed, saying Ortiz was “like a big brother.”

Sandoval is a career .294 hitter who had 16 homers and 73 RBI in the regular season this year, then hit .366 in the postseason while helping the Giants win a third World Series in five years.

A 30-year-old infielder who has never played the outfield in 1,634 pro games, Ramirez batted .300 with 13 homers and 71 RBI for Los Angeles this year. Cherington, who watched Ramirez learn to play shortstop in the minors, said he’s confident Ramirez can take on a new role.

For now the Red Sox are overloaded with outfielders and short on pitchers, having acquired Allen Craig and Yoenis Cespedes in July while shipping off four-fifths of the rotation.

“We’ve got a ways to go in the offseason,” Farrell said.

To clear the roster spots, the Red Sox designated first baseman-catcher Ryan Lavarnway and infielder Juan Francisco for assignment.