After Juan Uribe and Pablo Sandoval each delivered RBI singles, Torres blasted a pitch from Hisanori Takahashi (7-4) into the left field stands, giving the Giants a five-run inning and lifting them to their third straight win over the Mets.
Sandoval collected three hits and three RBI, and Uribe went 3-for-3.
The winner was Matt Cain (7-8), who held New York to two runs on four hits over seven innings of work.
Ike Davis homered and drove in three runs for the Mets, who lost for the sixth time in seven games.
2014 amfAR Inspiration Gala [PHOTOS]
Julius Randle breaks leg during NBA debut