The San Francisco Giants and third baseman Pablo Sandoval on Tuesday agreed to a three-year, $17.15 million contract, a source has told Mercury News staff writer Andrew Baggarly.

The contract will buy out Sandoval’s arbitration-eligible years. He will receive $3.2 million for the upcoming season, $5.7 in 2013 and $8.25 million in 2014, according to a tweet by Baggarly. The new deal also includes incentives.

Sandoval bounced back last season after struggling with weight issues in 2010. He was a first-time All-Star in 2011 and finished the year with a .315 batting average, 24 home runs and 70 RBI.