The 2007 NL Cy Young Award winner will start Sunday night's series finale against the Los Angeles Dodgers. The Giants held a half-game division lead in the NL West against their rival going into Saturday night's middle game at AT&T Park.
The Giants have plenty of familiarity with Peavy, who pitched for manager Bruce Bochy with the San Diego Padres in the playoffs in 2005-06.
''It's great to be reunited with Jake,'' Bochy said by text message. ''Look forward to working with him again.''
San Francisco missed the playoffs in 2013 after winning the World Series in 2010 and '12, and the club is committed to making another special October run.
The 33-year-old Peavy pitched one of his best games last Aug. 25 at Dodger Stadium. He tossed a three-hitter with five strikeouts and one walk in an 8-1 Red Sox victory.
San Francisco received cash from Boston and is sending right-hander Heath Hembree and lefty Edwin Escobar to the World Series champion Red Sox in the swap. Both players were optioned by the Red Sox to Triple-A Pawtucket.
''It provides Jake an opportunity to step right into a more ready pennant race out in the west,'' Boston manager John Farrell said. ''And we get two pitchers back we like.''
Peavy (1-9, 4.72 ERA) has been hurt by poor run support this season, receiving two runs or fewer of support in each of his past eight starts. He is in the final season of a $29 million, two-year contract.
''Going to miss him,'' Boston's Mike Napoli said. ''A great competitor. A great teammate. His record doesn't really show the kind of pitcher he is.''
Peavy is earning $14.5 million this season, with the Red Sox paying more than $3 million of his remaining salary for the year - $5.15 million.
Six weeks on the disabled list last year with a rib injury cost him a chance to have a conditional $15 million option for 2015 if he had reached 400 innings over 2013-14. He is at 268 2-3 heading into Sunday's outing.
Yusmeiro Petit had been scheduled to pitch Sunday for the Giants with right-hander Matt Cain on the disabled list.
''The impetus to execute the trade was accelerated by the news we got about Matt Cain yesterday becoming more and more tenuous,'' Giants general manager Brian Sabean said. ''The longer he stays in this dormant stage, the more we're going to seek a second opinion.''
The Giants made the deal without having to give up their top pitching prospect, Kyle Crick.
It's been a busy week for Sabean and assistant GM Bobby Evans.
On Friday, they promoted second baseman Dan Uggla from Triple-A Fresno only four days after they signed him to a minor league contract Monday. Uggla was released by Atlanta on July 18.
Escobar went 3-8 with a 5.11 ERA with 96 strikeouts in 20 games for Triple-A Fresno, while Hembree went 1-3 with a 3.89 ERA and 18 saves with 46 strikeouts in 41 appearances for Fresno this year.
Freelance writers Mark Didtler in St. Petersburg, Florida, and Rick Eymer contributed to this report.