The Giants sent pitching prospects Edwin Escobar and Heath Hembree to the Red Sox to get Peavy.
Peavy, 33, is 1-9 with a 4.72 ERA in 20 starts this season.
The Giants need a starting pitcher with right-hander Matt Cain on the disabled list with an elbow injury.
It marks the third time Peavy has been dealt in July. Boston acquired Peavy last July 30 from the Chicago White Sox in a three-team deal that also involved the Detroit Tigers. The White Sox had acquired Peavy from the Padres ahead of the trade deadline in 2009.
Copyright © 2015, The Baltimore Sun