Eduardo Nunez's time with the Giants is up as they have traded the third baseman to the Boston Red Sox.
The teams announced the trade shortly after the Giants beat the Pirates 11-3 on Tuesday night.
Fox Sports was the first to report the news.
The Giants will acquire minor league pitchers Shaun Anderson and Gregory Santos.
Anderson, Boston's third-round pick out of Florida in 2016, has a 3.42 ERA in 97.1 innings between Low-A Greenville and High-A Salem this season.
Santos, a 17-year-old right-handed pitcher, was signed by Boston out of the Dominican Republic in 2015. Pitching in the Dominican Summer League this season, Santos has allowed just three earned runs in 30 innings pitched.
Nunez was lifted for pinch-hitter in the bottom of the fifth inning Tuesday night and was seen hugging teammates as he left the dugout.
In 75 games with the Giants this season, Nunez hit .308/.334/.417 with 21 doubles, four home runs, 29 RBI and 17 stolen bases.
Nunez was acquired from the Twins last summer for two prospects.