Pablo Sandoval has an agreement in place with the Boston Red Sox, the free-agent third baseman's agent confirmed.

"Yes, we have an agreement with the Red Sox and we're on our way to Boston," Sandoval's agent, Gustavo Vasquez, told The Associated Press by telephone from Florida while about to board a plane to Boston.

The switch-hitting slugger earlier informed the San Francisco Giants he was leaving.

"Got the call. He is going to the Red Sox," Giants assistant general manager Bobby Evans told the AP earlier Monday.

"He has been with us through some of the greatest moments in San Francisco Giants history -- including all three World Series championships," the Giants said in a statement. "We will never forget his World Series MVP performance in 2012 and his numerous contributions to the 2014 championship. His connection with Giants fans -- young and old -- is truly special, and he will be greatly missed. We wish him nothing but the best in Boston."

Sandoval addressed his decision to leave San Francisco in an Instagram post:

The agreement comes at the same time as Boston's deal with free-agent infielder Hanley Ramirez. Ramirez agreed Monday to a four-year deal worth $88 million with a vesting option for a fifth year, a source told ESPNBoston.com.

Sandoval reportedly chose the Red Sox's offer over those from the Giants and San Diego Padres. All three offers were believed to be for five years and at least $90 million.

As the Giants have discussed Plan B moves in case they lost out on Sandoval, they've talked about the possibility of pursuing left-hander Jon Lester, sources told ESPN's Buster Olney. The Red Sox also remain engaged in talks with Lester about a possible reunion.

Sandoval, 28, hit .279 with 16 home runs and 73 RBIs last season. He has hit .294 with 106 homers and 462 RBIs in seven big league seasons, all with the Giants.

He has starred in the postseason, hitting .344 with six homers and 20 RBIs in 39 games, helping the Giants win three championships in five seasons. In Game 1 of the 2012 World Series against the Detroit Tigers, he became the first player in baseball history to homer in his first three at-bats in a World Series game. He went on to win the World Series MVP award.

Former teammate Barry Zito nicknamed Sandoval "Kung Fu Panda" after he acrobatically avoided a tag at home plate against the Dodgers in a game in 2008.

Sandoval, who reportedly rejected a three-year, $40 million contract extension offer from the Giants in March, was paid $8.25 million in 2014.

The Giants made a one-year qualifying offer of $15.3 million to Sandoval for 2015 that he rejected, ensuring them draft-pick compensation if he signs with another team.

Red Sox Add A Postseason Hero Pablo Sandoval's career postseason batting average of .344 is the best in baseball history among players with at least 150 plate appearances. And he has a .426 batting average in 50 career World Series plate appearances as he helped the Giants win three titles. Player BA Years Pablo Sandoval .344 2010-14 Steve Garvey .338 1974-84 George Brett .337 1976-85 Carlos Beltran .333 2004-13 -- ESPN Stats & Information

By adding Sandoval, the Red Sox are trying to upgrade a position in which they ranked 29th in baseball in OPS, with their .580 mark 121 percentage points below the league average of .701 at third base.

Although Ramirez played predominantly at shortstop for the Dodgers, he is unlikely to man the position for the Red Sox because of the presence of 22-year-old shortstop Xander Bogaerts, who is regarded as highly as Ramirez was after he signed with the Red Sox in 2000 as a teenager in the Dominican Republic. The Red Sox instead might target Ramirez to play in the outfield.

The Red Sox already have a logjam in the outfield, though, with potential starters in Yoenis Cespedes, Rusney Castillo, Mookie Betts, Shane Victorino and even Allen Craig, with Jackie Bradley Jr. potentially in reserve. The signing of Ramirez to play the outfield would suggest the Sox are planning to trade an outfielder, with Cespedes, who is a year from free agency, a leading candidate.

ESPNBoston.com's Gordon Edes and The Associated Press contributed to this report.